Handle TooManyRequests error (#53)

This commit is contained in:
Artem Piskun 2021-12-09 14:38:29 +03:00 committed by GitHub
parent 52eff84151
commit f16388f238
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View File

@ -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)
}

View File

@ -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"}
)