From 2fd8f3d0cea2268412ef3da3e604b9eb5d189fa1 Mon Sep 17 00:00:00 2001 From: Matt Gleich Date: Thu, 5 Dec 2024 09:51:23 -0500 Subject: [PATCH] feat: properly ignore warning errors Signed-off-by: Matt Gleich --- internal/apis/applemusic/api.go | 5 ++++- internal/apis/steam/achievements.go | 5 ++++- internal/apis/steam/games.go | 5 ++++- internal/apis/strava/api.go | 5 ++++- internal/apis/strava/tokens.go | 5 ++++- 5 files changed, 20 insertions(+), 5 deletions(-) diff --git a/internal/apis/applemusic/api.go b/internal/apis/applemusic/api.go index 3426a78..e75d912 100644 --- a/internal/apis/applemusic/api.go +++ b/internal/apis/applemusic/api.go @@ -1,6 +1,7 @@ package applemusic import ( + "errors" "fmt" "net/http" "strings" @@ -26,7 +27,9 @@ func sendAppleMusicAPIRequest[T any](path string) (T, error) { resp, err := apis.SendRequest[T](req) if err != nil { - lumber.Error(err, "failed to make apple music API request") + if !errors.Is(err, apis.WarningError) { + lumber.Error(err, "failed to make apple music API request") + } return zeroValue, err } return resp, nil diff --git a/internal/apis/steam/achievements.go b/internal/apis/steam/achievements.go index 50d6517..f244ed2 100644 --- a/internal/apis/steam/achievements.go +++ b/internal/apis/steam/achievements.go @@ -2,6 +2,7 @@ package steam import ( "encoding/json" + "errors" "fmt" "io" "net/http" @@ -108,7 +109,9 @@ func fetchGameAchievements(appID int32) (*float32, *[]achievement) { } gameSchema, err := apis.SendRequest[schemaGameResponse](req) if err != nil { - lumber.Error(err, "failed to get game schema for app id:", appID) + if !errors.Is(err, apis.WarningError) { + lumber.Error(err, "failed to get game schema for app id:", appID) + } return nil, nil } diff --git a/internal/apis/steam/games.go b/internal/apis/steam/games.go index e816a6a..c411f1f 100644 --- a/internal/apis/steam/games.go +++ b/internal/apis/steam/games.go @@ -1,6 +1,7 @@ package steam import ( + "errors" "fmt" "net/http" "net/url" @@ -55,7 +56,9 @@ func fetchRecentlyPlayedGames() ([]game, error) { } ownedGames, err := apis.SendRequest[ownedGamesResponse](req) if err != nil { - lumber.Error(err, "sending request for owned games failed") + if !errors.Is(err, apis.WarningError) { + lumber.Error(err, "sending request for owned games failed") + } return nil, err } diff --git a/internal/apis/strava/api.go b/internal/apis/strava/api.go index 92390d1..4e8b09c 100644 --- a/internal/apis/strava/api.go +++ b/internal/apis/strava/api.go @@ -1,6 +1,7 @@ package strava import ( + "errors" "fmt" "net/http" "strings" @@ -25,7 +26,9 @@ func sendStravaAPIRequest[T any](path string, tokens tokens) (T, error) { resp, err := apis.SendRequest[T](req) if err != nil { - lumber.Error(err, "failed to make strava API request") + if !errors.Is(err, apis.WarningError) { + lumber.Error(err, "failed to make strava API request") + } return zeroValue, err } return resp, nil diff --git a/internal/apis/strava/tokens.go b/internal/apis/strava/tokens.go index 7802e17..947684e 100644 --- a/internal/apis/strava/tokens.go +++ b/internal/apis/strava/tokens.go @@ -1,6 +1,7 @@ package strava import ( + "errors" "net/http" "net/url" "time" @@ -45,7 +46,9 @@ func (t *tokens) refreshIfNeeded() { tokens, err := apis.SendRequest[tokens](req) if err != nil { - lumber.Error(err, "failed to refresh tokens") + if !errors.Is(err, apis.WarningError) { + lumber.Error(err, "failed to refresh tokens") + } return }