Exception: TravelTime::Error
- Inherits:
-
StandardError
- Object
- StandardError
- TravelTime::Error
- Defined in:
- lib/travel_time/error.rb
Overview
The Error class wraps exceptions and provide useful information.
Constant Summary collapse
- DEFAULT_MESSAGE =
'Error while processing the request'
Instance Attribute Summary collapse
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#wrapped_exception ⇒ Object
readonly
Returns the value of attribute wrapped_exception.
Instance Method Summary collapse
- #additional_info ⇒ Object
- #description ⇒ Object
- #documentation_link ⇒ Object
- #error_code ⇒ Object
-
#initialize(message = nil, response: nil, exception: nil) ⇒ Error
constructor
A new instance of Error.
- #parse_message(message) ⇒ Object
Constructor Details
#initialize(message = nil, response: nil, exception: nil) ⇒ Error
Returns a new instance of Error.
10 11 12 13 14 15 |
# File 'lib/travel_time/error.rb', line 10 def initialize( = nil, response: nil, exception: nil) @response = response @wrapped_exception = exception exc = super(()) exc.set_backtrace(exception.backtrace) unless exception.nil? end |
Instance Attribute Details
#response ⇒ Object (readonly)
Returns the value of attribute response.
8 9 10 |
# File 'lib/travel_time/error.rb', line 8 def response @response end |
#wrapped_exception ⇒ Object (readonly)
Returns the value of attribute wrapped_exception.
8 9 10 |
# File 'lib/travel_time/error.rb', line 8 def wrapped_exception @wrapped_exception end |
Instance Method Details
#additional_info ⇒ Object
29 30 31 |
# File 'lib/travel_time/error.rb', line 29 def additional_info extract_from_body('additional_info') end |
#description ⇒ Object
21 22 23 |
# File 'lib/travel_time/error.rb', line 21 def description extract_from_body('description') end |
#documentation_link ⇒ Object
33 34 35 |
# File 'lib/travel_time/error.rb', line 33 def documentation_link extract_from_body('documentation_link') end |
#error_code ⇒ Object
25 26 27 |
# File 'lib/travel_time/error.rb', line 25 def error_code extract_from_body('error_code') end |
#parse_message(message) ⇒ Object
17 18 19 |
# File 'lib/travel_time/error.rb', line 17 def () || wrapped_exception&. || description || DEFAULT_MESSAGE end |