Skip to content

Commit

Permalink
fix: use http helpers to name http status codes
Browse files Browse the repository at this point in the history
  • Loading branch information
chriswk committed Dec 15, 2023
1 parent eace93e commit 7c8994d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,12 @@ func (r *repository) fetch() error {

func (r *repository) statusIsOK(resp *http.Response) error {
s := resp.StatusCode
if 200 <= s && s < 300 {
if http.StatusOK <= s && s < http.StatusMultipleChoices {
return nil
} else if s == 401 || s == 403 || s == 404 {
} else if s == http.StatusUnauthorized || s == http.StatusForbidden || s == http.StatusNotFound {
r.configurationError()
return fmt.Errorf("%s %s returned status code %d your SDK is most likely misconfigured, backing off to maximum (%f times our interval)", resp.Request.Method, resp.Request.URL, s, r.maxSkips)
} else if s == 429 || s >= 500 {
} else if s == http.StatusTooManyRequests || s >= http.StatusInternalServerError {
r.backoff()
return fmt.Errorf("%s %s returned status code %d, backing off (%f times our interval)", resp.Request.Method, resp.Request.URL, s, r.errors)
}
Expand Down

0 comments on commit 7c8994d

Please sign in to comment.