Skip to content

Commit

Permalink
feat: handle expected failed http status code
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Gleich <[email protected]>
  • Loading branch information
gleich committed Dec 11, 2024
1 parent b4a3232 commit 894a7df
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions internal/apis/steam/achievements.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,19 @@ func fetchGameAchievements(appID int32) (*float32, *[]achievement) {
return nil, nil
}
if resp.StatusCode != http.StatusOK {
lumber.ErrorMsg(
err := fmt.Errorf(
"status code of %d returned from API. Code of 200 expected from %s",
resp.StatusCode,
"when trying to get player achievements for",
appID,
string(body),
resp.Request.URL,
)
if resp.StatusCode == http.StatusBadGateway ||
resp.StatusCode == http.StatusGatewayTimeout ||
resp.StatusCode == http.StatusInternalServerError {
lumber.Warning(err)
return nil, nil
} else {
lumber.Error(err)
}
return nil, nil
}

Expand Down

0 comments on commit 894a7df

Please sign in to comment.