Exception: MaxApiClient::ApiError
- Defined in:
- lib/max_api_client/error.rb,
sig/max_api_client.rbs
Overview
Error raised for non-successful API responses.
Instance Attribute Summary collapse
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#status ⇒ Integer
readonly
Returns the value of attribute status.
Instance Method Summary collapse
- #code ⇒ Object
- #description ⇒ String
-
#initialize(status, response = {}) ⇒ ApiError
constructor
A new instance of ApiError.
Constructor Details
#initialize(status, response = {}) ⇒ ApiError
Returns a new instance of ApiError.
11 12 13 14 15 |
# File 'lib/max_api_client/error.rb', line 11 def initialize(status, response = {}) @status = status @response = response || {} super("#{status}: #{description}") end |
Instance Attribute Details
#response ⇒ Object (readonly)
Returns the value of attribute response.
9 10 11 |
# File 'lib/max_api_client/error.rb', line 9 def response @response end |
#status ⇒ Integer (readonly)
Returns the value of attribute status.
9 10 11 |
# File 'lib/max_api_client/error.rb', line 9 def status @status end |
Instance Method Details
#code ⇒ Object
17 18 19 |
# File 'lib/max_api_client/error.rb', line 17 def code response["code"] || response[:code] end |
#description ⇒ String
21 22 23 |
# File 'lib/max_api_client/error.rb', line 21 def description response["message"] || response[:message] || "Unknown API error" end |