Exception: VisionAPI::RateLimitError

Inherits:
APIError show all
Defined in:
lib/vision_api/errors.rb

Overview

429 — sleep for #retry_after seconds. Do not invent a backoff.

Direct Known Subclasses

TooManyTasksError

Constant Summary

Constants inherited from APIError

APIError::RETRYABLE_CODES

Instance Attribute Summary

Attributes inherited from APIError

#code, #details, #headers, #request_id, #status

Instance Method Summary collapse

Methods inherited from APIError

#initialize, #retryable?

Constructor Details

This class inherits a constructor from VisionAPI::APIError

Instance Method Details

#retry_afterFloat

Returns the server's own number, in seconds. Honor it rather than guessing.

Returns:

  • (Float)

    the server's own number, in seconds. Honor it rather than guessing.



94
95
96
97
98
99
100
101
102
103
# File 'lib/vision_api/errors.rb', line 94

def retry_after
  header = headers["retry-after"]
  value = header.to_f if header
  return value if value&.positive?

  detail = details["retry_after"]
  return detail.to_f if detail.is_a?(Numeric) && detail.positive?

  2.0
end