Exception: QuickTravel::AdapterError
- Inherits:
-
StandardError
- Object
- StandardError
- QuickTravel::AdapterError
- Defined in:
- lib/quick_travel/adapter_error.rb
Instance Attribute Summary collapse
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
- #error_type ⇒ Object
-
#initialize(response) ⇒ AdapterError
constructor
A new instance of AdapterError.
Constructor Details
#initialize(response) ⇒ AdapterError
Returns a new instance of AdapterError.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/quick_travel/adapter_error.rb', line 6 def initialize(response) case response when String @response = { 'error' => response } @status = 422 when HTTParty::Response @response = response.parsed_response @status = response.code else fail "Unexpected response type #{response.class}"\ "Should be String or HTTParty::Response" end = if @response.is_a? Hash @response.fetch('error', "We're sorry, but something went wrong. Please call us.") else @response end super() end |
Instance Attribute Details
#response ⇒ Object (readonly)
Returns the value of attribute response.
3 4 5 |
# File 'lib/quick_travel/adapter_error.rb', line 3 def response @response end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
4 5 6 |
# File 'lib/quick_travel/adapter_error.rb', line 4 def status @status end |
Instance Method Details
#error_type ⇒ Object
27 28 29 |
# File 'lib/quick_travel/adapter_error.rb', line 27 def error_type @response.fetch('error_type', 'unspecified') end |