Exception: Fizzy::APIError
Overview
Raised for generic API errors.
Instance Attribute Summary
Attributes inherited from Error
#cause, #code, #hint, #http_status, #request_id, #retry_after, #retryable
Class Method Summary collapse
-
.from_status(status, message = nil) ⇒ APIError
Creates an APIError from an HTTP status code.
Instance Method Summary collapse
-
#initialize(message, http_status: nil, hint: nil, retryable: false, cause: nil) ⇒ APIError
constructor
A new instance of APIError.
Methods inherited from Error
#exit_code, exit_code_for, #retryable?
Constructor Details
#initialize(message, http_status: nil, hint: nil, retryable: false, cause: nil) ⇒ APIError
Returns a new instance of APIError.
192 193 194 195 196 197 198 199 200 201 |
# File 'lib/fizzy/errors.rb', line 192 def initialize(, http_status: nil, hint: nil, retryable: false, cause: nil) super( code: ErrorCode::API, message: , hint: hint, http_status: http_status, retryable: retryable, cause: cause ) end |
Class Method Details
.from_status(status, message = nil) ⇒ APIError
Creates an APIError from an HTTP status code.
207 208 209 210 211 |
# File 'lib/fizzy/errors.rb', line 207 def self.from_status(status, = nil) ||= "Request failed (HTTP #{status})" retryable = status >= 500 && status < 600 new(, http_status: status, retryable: retryable) end |