Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add RateLimitError type, detect and return it when appropriate. #277

Closed
wants to merge 2 commits into from
Closed

Add RateLimitError type, detect and return it when appropriate. #277

wants to merge 2 commits into from

Conversation

dmitshur
Copy link
Member

Fixes #152.

Add tests for RateLimitError.

Refactor populateRate into a more general parseRate.

Here's a sample error returned when hitting the rate limit:

GET https://api.github.com/users/shurcooL: 403 API rate limit exceeded for xxx.xxx.xxx.xxx. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.); rate reset in 15m8.193650147s

Fixes #152.

Add tests for RateLimitError.

Refactor populateRate into a more general parseRate.
@@ -427,10 +443,18 @@ func CheckResponse(r *http.Response) error {
if err == nil && data != nil {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it's worth expanding documentation of CheckError to mention both TwoFactorAuthError and RateLimitError error types?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, probably so.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 76866e1. PTAL.

@willnorris
Copy link
Collaborator

rebased onto current master and merged as c3f5683 and 39d7560. thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants