Exception: Api2Convert::ApiError
- Defined in:
- lib/api2convert/errors.rb
Overview
An HTTP error response (status >= 400).
Used directly for a 4xx with no more specific subclass; specific statuses map to the dedicated subclasses below.
Direct Known Subclasses
AuthenticationError, NotFoundError, PaymentRequiredError, RateLimitError, ServerError, ValidationError
Instance Attribute Summary collapse
-
#body ⇒ Hash
readonly
The decoded JSON error body, or
{}when absent/unparseable. -
#request_id ⇒ String?
readonly
The
X-Request-Idresponse header, if any. -
#status_code ⇒ Integer
readonly
The HTTP status code.
Instance Method Summary collapse
-
#initialize(message, status_code: 0, request_id: nil, body: nil) ⇒ ApiError
constructor
A new instance of ApiError.
Constructor Details
#initialize(message, status_code: 0, request_id: nil, body: nil) ⇒ ApiError
Returns a new instance of ApiError.
28 29 30 31 32 33 |
# File 'lib/api2convert/errors.rb', line 28 def initialize(, status_code: 0, request_id: nil, body: nil) super() @status_code = status_code @request_id = request_id @body = body || {} end |
Instance Attribute Details
#body ⇒ Hash (readonly)
Returns the decoded JSON error body, or {} when absent/unparseable.
26 27 28 |
# File 'lib/api2convert/errors.rb', line 26 def body @body end |
#request_id ⇒ String? (readonly)
Returns the X-Request-Id response header, if any. Quote it
in support requests.
24 25 26 |
# File 'lib/api2convert/errors.rb', line 24 def request_id @request_id end |
#status_code ⇒ Integer (readonly)
Returns the HTTP status code.
21 22 23 |
# File 'lib/api2convert/errors.rb', line 21 def status_code @status_code end |