Handle TooManyRequests error (#53)
This commit is contained in:
		@@ -105,6 +105,8 @@ func request(path string, params url.Values, resp interface{}) error {
 | 
				
			|||||||
		switch response.StatusCode {
 | 
							switch response.StatusCode {
 | 
				
			||||||
		case http.StatusUnauthorized:
 | 
							case http.StatusUnauthorized:
 | 
				
			||||||
			return ErrUnauthorized
 | 
								return ErrUnauthorized
 | 
				
			||||||
 | 
							case http.StatusTooManyRequests:
 | 
				
			||||||
 | 
								return ErrTooManyRequests
 | 
				
			||||||
		default:
 | 
							default:
 | 
				
			||||||
			return fmt.Errorf("unknown error: %s", response.Status)
 | 
								return fmt.Errorf("unknown error: %s", response.Status)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -16,10 +16,11 @@ func (e *Error) Error() string {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// APIErrors
 | 
					// APIErrors
 | 
				
			||||||
var (
 | 
					var (
 | 
				
			||||||
	ErrUnauthorized         = &Error{"authentication required"}
 | 
					 | 
				
			||||||
	ErrCurrencyNotSupported = &Error{"currency does not supported"}
 | 
						ErrCurrencyNotSupported = &Error{"currency does not supported"}
 | 
				
			||||||
	ErrUserAgentInvalid     = &Error{"invalid user-agent"}
 | 
					 | 
				
			||||||
	ErrInvalidReleaseID     = &Error{"invalid release id"}
 | 
						ErrInvalidReleaseID     = &Error{"invalid release id"}
 | 
				
			||||||
	ErrInvalidSortKey       = &Error{"invalid sort key"}
 | 
						ErrInvalidSortKey       = &Error{"invalid sort key"}
 | 
				
			||||||
	ErrInvalidUsername      = &Error{"invalid username"}
 | 
						ErrInvalidUsername      = &Error{"invalid username"}
 | 
				
			||||||
 | 
						ErrTooManyRequests      = &Error{"too many requests"}
 | 
				
			||||||
 | 
						ErrUnauthorized         = &Error{"authentication required"}
 | 
				
			||||||
 | 
						ErrUserAgentInvalid     = &Error{"invalid user-agent"}
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user