Exception: Hellio::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Hellio::Error
- Defined in:
- lib/hellio/errors.rb
Overview
Base error for every failure returned by the Hellio Messaging API. Carries the HTTP status code and the parsed response body so callers can inspect the details (for 422, read #errors for field-level messages).
Direct Known Subclasses
InsufficientBalanceError, InvalidApiTokenError, RateLimitError, ServiceUnavailableError, ValidationError
Instance Attribute Summary collapse
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#status_code ⇒ Object
readonly
Returns the value of attribute status_code.
Instance Method Summary collapse
-
#errors ⇒ Object
Field-level validation details, present on 422 responses.
-
#initialize(message = nil, status_code: nil, response: nil) ⇒ Error
constructor
A new instance of Error.
Constructor Details
#initialize(message = nil, status_code: nil, response: nil) ⇒ Error
Returns a new instance of Error.
10 11 12 13 14 |
# File 'lib/hellio/errors.rb', line 10 def initialize( = nil, status_code: nil, response: nil) super() @status_code = status_code @response = response end |
Instance Attribute Details
#response ⇒ Object (readonly)
Returns the value of attribute response.
8 9 10 |
# File 'lib/hellio/errors.rb', line 8 def response @response end |
#status_code ⇒ Object (readonly)
Returns the value of attribute status_code.
8 9 10 |
# File 'lib/hellio/errors.rb', line 8 def status_code @status_code end |
Instance Method Details
#errors ⇒ Object
Field-level validation details, present on 422 responses.
17 18 19 20 21 |
# File 'lib/hellio/errors.rb', line 17 def errors return nil unless response.is_a?(Hash) response["errors"] end |