diff --git a/README.md b/README.md index 30d6f1f50..de0d89950 100644 --- a/README.md +++ b/README.md @@ -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. @@ -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 diff --git a/lib/twitter/error/rate_limited.rb b/lib/twitter/error/too_many_requests.rb similarity index 57% rename from lib/twitter/error/rate_limited.rb rename to lib/twitter/error/too_many_requests.rb index be0e49c41..a82779666 100644 --- a/lib/twitter/error/rate_limited.rb +++ b/lib/twitter/error/too_many_requests.rb @@ -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 diff --git a/lib/twitter/response/raise_error.rb b/lib/twitter/response/raise_error.rb index 67cf55102..86788a07a 100644 --- a/lib/twitter/response/raise_error.rb +++ b/lib/twitter/response/raise_error.rb @@ -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'