Exception: DilisensePepClient::RateLimitError
- Defined in:
- lib/dilisense_pep_client/errors.rb
Overview
Rate limiting errors
Instance Attribute Summary collapse
-
#limit ⇒ Object
readonly
Returns the value of attribute limit.
-
#remaining ⇒ Object
readonly
Returns the value of attribute remaining.
-
#retry_after ⇒ Object
readonly
Returns the value of attribute retry_after.
Attributes inherited from APIError
Attributes inherited from Error
#context, #error_code, #request_id, #timestamp
Instance Method Summary collapse
-
#initialize(message, retry_after: nil, limit: nil, remaining: nil, **options) ⇒ RateLimitError
constructor
A new instance of RateLimitError.
- #retryable? ⇒ Boolean
- #suggested_retry_delay ⇒ Object
Methods inherited from APIError
#client_error?, #server_error?
Methods inherited from Error
Constructor Details
#initialize(message, retry_after: nil, limit: nil, remaining: nil, **options) ⇒ RateLimitError
Returns a new instance of RateLimitError.
265 266 267 268 269 270 271 272 273 274 275 276 277 278 |
# File 'lib/dilisense_pep_client/errors.rb', line 265 def initialize(, retry_after: nil, limit: nil, remaining: nil, **) @retry_after = retry_after @limit = limit @remaining = remaining context = { retry_after: retry_after, rate_limit: limit, rate_remaining: remaining, reset_time: retry_after ? Time.now + retry_after : nil }.merge(.fetch(:context, {})) super(, error_code: "RATE_LIMITED", context: context, **) end |
Instance Attribute Details
#limit ⇒ Object (readonly)
Returns the value of attribute limit.
263 264 265 |
# File 'lib/dilisense_pep_client/errors.rb', line 263 def limit @limit end |
#remaining ⇒ Object (readonly)
Returns the value of attribute remaining.
263 264 265 |
# File 'lib/dilisense_pep_client/errors.rb', line 263 def remaining @remaining end |
#retry_after ⇒ Object (readonly)
Returns the value of attribute retry_after.
263 264 265 |
# File 'lib/dilisense_pep_client/errors.rb', line 263 def retry_after @retry_after end |
Instance Method Details
#retryable? ⇒ Boolean
280 281 282 |
# File 'lib/dilisense_pep_client/errors.rb', line 280 def retryable? true end |
#suggested_retry_delay ⇒ Object
284 285 286 |
# File 'lib/dilisense_pep_client/errors.rb', line 284 def suggested_retry_delay @retry_after || 60 # Default to 60 seconds if not specified end |