adds logging to sentry of api failled api calls

This commit is contained in:
Seraphim Strub 2023-04-23 00:51:02 +02:00
parent df441014ed
commit a3349fe7b1

View file

@ -50,8 +50,6 @@ func main() {
// Flush buffered events before the program terminates.
defer sentry.Flush(2 * time.Second)
sentry.CaptureMessage("DEBUG: dealsbot started")
log.Printf("INFO: starting dealsbot...")
log.Printf("INFO: disgo version: %v", disgo.Version)
@ -71,15 +69,16 @@ func main() {
case <-ticker.C:
var apis []api.Api
apis = append(apis, api.NewUbsioftApi(), api.NewEpicApi(), api.NewSteamApi(), api.NewGogApi(), api.NewHumbleBundleApi())
for _, api := range apis {
err := api.Load()
for _, a := range apis {
err := a.Load()
if err != nil {
sentry.CaptureException(fmt.Errorf("ERROR: loading from api: %w", err))
log.Printf("ERROR: %v", err)
}
}
var deals []api.Deal
for _, api := range apis {
apiDeals := api.Get()
for _, a := range apis {
apiDeals := a.Get()
deals = append(deals, apiDeals...)
}
@ -116,6 +115,7 @@ func main() {
}()
log.Printf("INFO: dealsbot is now running. Press CTRL-C to exit.")
sentry.CaptureMessage("DEBUG: dealsbot started")
s := make(chan os.Signal, 1)
signal.Notify(s, syscall.SIGINT, syscall.SIGTERM, os.Interrupt)
<-s