Skip to content

Commit

Permalink
Rename Twitter::Error::RateLimited to Twitter::Error::TooManyRequests
Browse files Browse the repository at this point in the history
Alias Twitter::Error::RateLimited to Twitter::Error::TooManyRequests for
backward compatibility.
  • Loading branch information
sferik committed Oct 6, 2012
1 parent c5268e3 commit 0f51791
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ num_attempts = 0
begin
num_attempts += 1
retweets = Twitter.retweeted_by_user("sferik")
rescue Twitter::Error::RateLimited => error
rescue Twitter::Error::TooManyRequests => error
if num_attempts <= MAX_ATTEMPTS
# NOTE: Your process could go to sleep for up to 15 minutes but if you
# retry any sooner, it will almost certainly fail with the same exception.
Expand Down Expand Up @@ -139,15 +139,15 @@ removed.
It's worth mentioning new error classes:

* `Twitter::Error::GatewayTimeout`
* `Twitter::Error::RateLimited`
* `Twitter::Error::TooManyRequests`
* `Twitter::Error::UnprocessableEntity`

In previous versions of this library, rate limit errors were indicated by
raising either `Twitter::Error::BadRequest` or
`Twitter::Error::EnhanceYourCalm` (for the Search API). As of version 4, the
library will raise `Twitter::Error::RateLimited` for all rate limit errors. The
`Twitter::Error::EnhanceYourCalm` class has been aliased to
`Twitter::Error::RateLimited`.
library will raise `Twitter::Error::TooManyRequests` for all rate limit errors.
The `Twitter::Error::EnhanceYourCalm` class has been aliased to
`Twitter::Error::TooManyRequests`.

### Identity Map

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
module Twitter
class Error
# Raised when Twitter returns the HTTP status code 429
class RateLimited < Twitter::Error::ClientError
class TooManyRequests < Twitter::Error::ClientError
HTTP_STATUS_CODE = 429
end
EnhanceYourCalm = RateLimited
EnhanceYourCalm = TooManyRequests
RateLimited = TooManyRequests
end
end
2 changes: 1 addition & 1 deletion lib/twitter/response/raise_error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
require 'twitter/error/internal_server_error'
require 'twitter/error/not_acceptable'
require 'twitter/error/not_found'
require 'twitter/error/rate_limited'
require 'twitter/error/service_unavailable'
require 'twitter/error/too_many_requests'
require 'twitter/error/unauthorized'
require 'twitter/error/unprocessable_entity'

Expand Down

0 comments on commit 0f51791

Please sign in to comment.