Skip to content

Commit

Permalink
Handle TooManyRequests error (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
irlndts authored Dec 9, 2021
1 parent 52eff84 commit f16388f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions discogs.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ func request(path string, params url.Values, resp interface{}) error {
switch response.StatusCode {
case http.StatusUnauthorized:
return ErrUnauthorized
case http.StatusTooManyRequests:
return ErrTooManyRequests
default:
return fmt.Errorf("unknown error: %s", response.Status)
}
Expand Down
5 changes: 3 additions & 2 deletions errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ func (e *Error) Error() string {

// APIErrors
var (
ErrUnauthorized = &Error{"authentication required"}
ErrCurrencyNotSupported = &Error{"currency does not supported"}
ErrUserAgentInvalid = &Error{"invalid user-agent"}
ErrInvalidReleaseID = &Error{"invalid release id"}
ErrInvalidSortKey = &Error{"invalid sort key"}
ErrInvalidUsername = &Error{"invalid username"}
ErrTooManyRequests = &Error{"too many requests"}
ErrUnauthorized = &Error{"authentication required"}
ErrUserAgentInvalid = &Error{"invalid user-agent"}
)

0 comments on commit f16388f

Please sign in to comment.