Class: Strava::Errors::RatelimitError
- Inherits:
-
Faraday::ClientError
- Object
- Faraday::ClientError
- Strava::Errors::RatelimitError
- Defined in:
- lib/strava/errors/ratelimit_error.rb
Overview
Exception raised when API rate limits are exceeded.
Strava enforces rate limits on API requests to prevent abuse. When your application exceeds these limits (either per 15 minutes or per day), the API returns a 429 Too Many Requests response, which triggers this exception.
This error includes rate limit information extracted from the response headers, allowing you to determine current usage and when limits will reset.
Instance Attribute Summary collapse
-
#ratelimit ⇒ Strava::Api::Ratelimit
readonly
Rate limit information from response headers.
Instance Method Summary collapse
-
#errors ⇒ Array?
Returns detailed error information from the API response.
-
#headers ⇒ Hash
Returns the HTTP response headers.
-
#initialize(env, response) ⇒ RatelimitError
constructor
Initialize a new rate limit error.
-
#message ⇒ String
Returns the error message from the API response.
Constructor Details
#initialize(env, response) ⇒ RatelimitError
Initialize a new rate limit error.
28 29 30 31 |
# File 'lib/strava/errors/ratelimit_error.rb', line 28 def initialize(env, response) @ratelimit = Strava::Api::Ratelimit.new(env.response) super(response) end |
Instance Attribute Details
#ratelimit ⇒ Strava::Api::Ratelimit (readonly)
Returns Rate limit information from response headers.
20 21 22 |
# File 'lib/strava/errors/ratelimit_error.rb', line 20 def ratelimit @ratelimit end |
Instance Method Details
#errors ⇒ Array?
Returns detailed error information from the API response.
56 57 58 |
# File 'lib/strava/errors/ratelimit_error.rb', line 56 def errors response[:body]['errors'] end |
#headers ⇒ Hash
Returns the HTTP response headers.
47 48 49 |
# File 'lib/strava/errors/ratelimit_error.rb', line 47 def headers response[:headers] end |
#message ⇒ String
Returns the error message from the API response.
38 39 40 |
# File 'lib/strava/errors/ratelimit_error.rb', line 38 def response[:body]['message'] || super end |