Exception: Zazu::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Zazu::Error
- Defined in:
- lib/zazu/errors.rb
Overview
Base class for every Zazu SDK error.
Carries the HTTP status, the API request id (header ‘X-Request-Id`), the parsed error type from the API (`error.type`), and the raw response body so callers can introspect anything the SDK didn’t explicitly model.
Direct Known Subclasses
ArgumentError, AuthenticationError, ConfigurationError, ConnectionError, ForbiddenError, NotFoundError, RateLimitError, ServerError, ValidationError
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#param ⇒ Object
readonly
Returns the value of attribute param.
-
#request_id ⇒ Object
readonly
Returns the value of attribute request_id.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(message = nil, status: nil, request_id: nil, type: nil, param: nil, body: nil) ⇒ Error
constructor
A new instance of Error.
- #to_h ⇒ Object
Constructor Details
#initialize(message = nil, status: nil, request_id: nil, type: nil, param: nil, body: nil) ⇒ Error
Returns a new instance of Error.
13 14 15 16 17 18 19 20 |
# File 'lib/zazu/errors.rb', line 13 def initialize( = nil, status: nil, request_id: nil, type: nil, param: nil, body: nil) super() @status = status @request_id = request_id @type = type @param = param @body = body end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
11 12 13 |
# File 'lib/zazu/errors.rb', line 11 def body @body end |
#param ⇒ Object (readonly)
Returns the value of attribute param.
11 12 13 |
# File 'lib/zazu/errors.rb', line 11 def param @param end |
#request_id ⇒ Object (readonly)
Returns the value of attribute request_id.
11 12 13 |
# File 'lib/zazu/errors.rb', line 11 def request_id @request_id end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
11 12 13 |
# File 'lib/zazu/errors.rb', line 11 def status @status end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
11 12 13 |
# File 'lib/zazu/errors.rb', line 11 def type @type end |
Instance Method Details
#to_h ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/zazu/errors.rb', line 22 def to_h { error: self.class.name.split("::").last, message:, status:, request_id:, type:, param: }.compact end |