Exception: RubyPi::RateLimitError

Inherits:
ApiError show all
Defined in:
lib/ruby_pi/errors.rb

Overview

Raised when the API returns a rate limit response (HTTP 429). The caller should back off and retry after the indicated period.

Instance Attribute Summary collapse

Attributes inherited from ApiError

#response_body, #status_code

Instance Method Summary collapse

Constructor Details

#initialize(message = nil, retry_after: nil, response_body: nil) ⇒ RateLimitError

Returns a new instance of RateLimitError.

Parameters:

  • message (String) (defaults to: nil)

    human-readable error description

  • retry_after (Float, nil) (defaults to: nil)

    seconds to wait before retrying

  • response_body (String, nil) (defaults to: nil)

    raw response body



61
62
63
64
# File 'lib/ruby_pi/errors.rb', line 61

def initialize(message = nil, retry_after: nil, response_body: nil)
  @retry_after = retry_after
  super(message || "Rate limit exceeded", status_code: 429, response_body: response_body)
end

Instance Attribute Details

#retry_afterFloat? (readonly)

Returns suggested retry delay in seconds, if provided by the API.

Returns:

  • (Float, nil)

    suggested retry delay in seconds, if provided by the API



56
57
58
# File 'lib/ruby_pi/errors.rb', line 56

def retry_after
  @retry_after
end