Exception: Fizzy::RateLimitError

Inherits:
Error
  • Object
show all
Defined in:
lib/fizzy/errors.rb

Overview

Raised when rate limited (429).

Instance Attribute Summary

Attributes inherited from Error

#cause, #code, #hint, #http_status, #request_id, #retry_after, #retryable

Instance Method Summary collapse

Methods inherited from Error

#exit_code, exit_code_for, #retryable?

Constructor Details

#initialize(retry_after: nil, cause: nil) ⇒ RateLimitError

Returns a new instance of RateLimitError.



163
164
165
166
167
168
169
170
171
172
173
174
# File 'lib/fizzy/errors.rb', line 163

def initialize(retry_after: nil, cause: nil)
  hint = retry_after ? "Try again in #{retry_after} seconds" : "Please slow down requests"
  super(
    code: ErrorCode::RATE_LIMIT,
    message: "Rate limit exceeded",
    hint: hint,
    http_status: 429,
    retryable: true,
    retry_after: retry_after,
    cause: cause
  )
end