Exception: Forem::RateLimitError

Inherits:
ForemError
  • Object
show all
Defined in:
lib/forem/errors.rb

Overview

Raised when the server responds with HTTP 429 Too Many Requests.

The client has exceeded its request quota. The library will automatically retry rate-limited requests up to Configuration#max_network_retries times, honoring integer Retry-After seconds when supplied and otherwise using exponential back-off.

Instance Attribute Summary

Attributes inherited from ForemError

#code, #http_body, #http_headers, #http_status

Instance Method Summary collapse

Methods inherited from ForemError

#initialize

Constructor Details

This class inherits a constructor from Forem::ForemError

Instance Method Details

#retry_afterInteger?

Return the number of seconds requested by the server before retrying.

Returns:

  • (Integer, nil)

    Retry-After seconds when the normalized header contains only ASCII decimal digits, or nil otherwise.



100
101
102
103
# File 'lib/forem/errors.rb', line 100

def retry_after
  value = http_headers&.fetch("retry-after", nil)
  Integer(value, 10) if value.is_a?(String) && value.match?(/\A[0-9]+\z/)
end