Exception: Anypost::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Anypost::Error
- Defined in:
- lib/anypost/errors.rb
Overview
Base class for every error raised by the SDK.
Branch on #type (the stable, machine-readable code) rather than on the HTTP status or the message text.
Direct Known Subclasses
APIConnectionError, APIError, AuthenticationError, ConflictError, IdempotencyMismatchError, NotFoundError, PayloadTooLargeError, PermissionError, RateLimitError, ValidationError
Instance Attribute Summary collapse
-
#raw ⇒ Object
readonly
The parsed response body, or the underlying cause.
-
#request_id ⇒ String?
readonly
Request id from the response, when present.
-
#status ⇒ Integer?
readonly
HTTP status, or nil when no response was received.
-
#type ⇒ String
readonly
Stable, machine-readable error type.
Instance Method Summary collapse
-
#initialize(message, type:, status: nil, request_id: nil, raw: nil) ⇒ Error
constructor
A new instance of Error.
Constructor Details
#initialize(message, type:, status: nil, request_id: nil, raw: nil) ⇒ Error
Returns a new instance of Error.
20 21 22 23 24 25 26 |
# File 'lib/anypost/errors.rb', line 20 def initialize(, type:, status: nil, request_id: nil, raw: nil) super() @type = type @status = status @request_id = request_id @raw = raw end |
Instance Attribute Details
#raw ⇒ Object (readonly)
Returns the parsed response body, or the underlying cause.
18 19 20 |
# File 'lib/anypost/errors.rb', line 18 def raw @raw end |
#request_id ⇒ String? (readonly)
Returns request id from the response, when present.
16 17 18 |
# File 'lib/anypost/errors.rb', line 16 def request_id @request_id end |
#status ⇒ Integer? (readonly)
Returns HTTP status, or nil when no response was received.
14 15 16 |
# File 'lib/anypost/errors.rb', line 14 def status @status end |
#type ⇒ String (readonly)
Returns stable, machine-readable error type.
12 13 14 |
# File 'lib/anypost/errors.rb', line 12 def type @type end |