Exception: Latitude::RateLimitError

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

Instance Attribute Summary

Attributes inherited from APIError

#entries, #http_body, #http_headers, #http_status, #json_body, #request_id

Instance Method Summary collapse

Methods inherited from APIError

#code, #detail, #initialize, #title

Constructor Details

This class inherits a constructor from Latitude::APIError

Instance Method Details

#retry_afterObject



104
105
106
107
108
109
110
111
112
# File 'lib/latitude/api/errors.rb', line 104

def retry_after
  meta_value = entries.map { |e| e.meta["retry_after"] }.compact.first
  return Integer(meta_value) if meta_value

  header_value = http_headers["retry-after"] || http_headers["Retry-After"]
  return Integer(header_value) if header_value && header_value.to_s.match?(/\A\d+\z/)

  nil
end