Exception: SmartcarError
- Inherits:
-
StandardError
- Object
- StandardError
- SmartcarError
- Defined in:
- lib/smartcar_error.rb
Overview
Custom SmartcarError class to represent errors from Smartcar APIs.
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#detail ⇒ Object
readonly
Returns the value of attribute detail.
-
#doc_url ⇒ Object
readonly
Returns the value of attribute doc_url.
-
#request_id ⇒ Object
readonly
Returns the value of attribute request_id.
-
#resolution ⇒ Object
readonly
Returns the value of attribute resolution.
-
#retry_after ⇒ Object
readonly
Returns the value of attribute retry_after.
-
#status_code ⇒ Object
readonly
Returns the value of attribute status_code.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(status, body, headers) ⇒ SmartcarError
constructor
A new instance of SmartcarError.
Constructor Details
#initialize(status, body, headers) ⇒ SmartcarError
Returns a new instance of SmartcarError.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/smartcar_error.rb', line 7 def initialize(status, body, headers) @status_code = status if body.is_a?(String) super(body) @request_id = headers['sc-request-id'] return end @retry_after = headers['retry-after'] body = coerce_attributes(body) super("#{body[:type]}:#{body[:code]} - #{body[:description]}") @request_id = body[:requestId] || headers['sc-request-id'] set_attributes(body) end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
5 6 7 |
# File 'lib/smartcar_error.rb', line 5 def code @code end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
5 6 7 |
# File 'lib/smartcar_error.rb', line 5 def description @description end |
#detail ⇒ Object (readonly)
Returns the value of attribute detail.
5 6 7 |
# File 'lib/smartcar_error.rb', line 5 def detail @detail end |
#doc_url ⇒ Object (readonly)
Returns the value of attribute doc_url.
5 6 7 |
# File 'lib/smartcar_error.rb', line 5 def doc_url @doc_url end |
#request_id ⇒ Object (readonly)
Returns the value of attribute request_id.
5 6 7 |
# File 'lib/smartcar_error.rb', line 5 def request_id @request_id end |
#resolution ⇒ Object (readonly)
Returns the value of attribute resolution.
5 6 7 |
# File 'lib/smartcar_error.rb', line 5 def resolution @resolution end |
#retry_after ⇒ Object (readonly)
Returns the value of attribute retry_after.
5 6 7 |
# File 'lib/smartcar_error.rb', line 5 def retry_after @retry_after end |
#status_code ⇒ Object (readonly)
Returns the value of attribute status_code.
5 6 7 |
# File 'lib/smartcar_error.rb', line 5 def status_code @status_code end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
5 6 7 |
# File 'lib/smartcar_error.rb', line 5 def type @type end |