Exception: Onetime::APIError
- Defined in:
- lib/onetime/errors.rb
Overview
Base class for errors returned by the API (HTTP status >= 400).
Carries the structured fields from the ADR-013 wire format ({ error:, error_type:, ... }) as well as the legacy v1 { message: } shape, so callers get a consistent interface across API versions.
Direct Known Subclasses
AuthenticationError, BadRequestError, ConflictError, ForbiddenError, NotFoundError, RateLimitError, ServerError
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#entitlement ⇒ Object
readonly
Returns the value of attribute entitlement.
-
#error_key ⇒ Object
readonly
Returns the value of attribute error_key.
-
#error_type ⇒ Object
readonly
Returns the value of attribute error_type.
-
#field ⇒ Object
readonly
Returns the value of attribute field.
-
#http_status ⇒ Object
readonly
Returns the value of attribute http_status.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#retry_after ⇒ Object
readonly
Returns the value of attribute retry_after.
Instance Method Summary collapse
-
#initialize(message = nil, http_status: nil, error_type: nil, code: nil, field: nil, error_key: nil, retry_after: nil, entitlement: nil, body: nil, response: nil) ⇒ APIError
constructor
A new instance of APIError.
Constructor Details
#initialize(message = nil, http_status: nil, error_type: nil, code: nil, field: nil, error_key: nil, retry_after: nil, entitlement: nil, body: nil, response: nil) ⇒ APIError
Returns a new instance of APIError.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/onetime/errors.rb', line 31 def initialize( = nil, http_status: nil, error_type: nil, code: nil, field: nil, error_key: nil, retry_after: nil, entitlement: nil, body: nil, response: nil) super() @http_status = http_status @error_type = error_type @code = code @field = field @error_key = error_key @retry_after = retry_after @entitlement = entitlement @body = body @response = response end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
28 29 30 |
# File 'lib/onetime/errors.rb', line 28 def body @body end |
#code ⇒ Object (readonly)
Returns the value of attribute code.
28 29 30 |
# File 'lib/onetime/errors.rb', line 28 def code @code end |
#entitlement ⇒ Object (readonly)
Returns the value of attribute entitlement.
28 29 30 |
# File 'lib/onetime/errors.rb', line 28 def entitlement @entitlement end |
#error_key ⇒ Object (readonly)
Returns the value of attribute error_key.
28 29 30 |
# File 'lib/onetime/errors.rb', line 28 def error_key @error_key end |
#error_type ⇒ Object (readonly)
Returns the value of attribute error_type.
28 29 30 |
# File 'lib/onetime/errors.rb', line 28 def error_type @error_type end |
#field ⇒ Object (readonly)
Returns the value of attribute field.
28 29 30 |
# File 'lib/onetime/errors.rb', line 28 def field @field end |
#http_status ⇒ Object (readonly)
Returns the value of attribute http_status.
28 29 30 |
# File 'lib/onetime/errors.rb', line 28 def http_status @http_status end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
28 29 30 |
# File 'lib/onetime/errors.rb', line 28 def response @response end |
#retry_after ⇒ Object (readonly)
Returns the value of attribute retry_after.
28 29 30 |
# File 'lib/onetime/errors.rb', line 28 def retry_after @retry_after end |