Exception: Attio::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Attio::Error
- Defined in:
- lib/attio.rb,
lib/attio/errors.rb
Overview
Base error class for all Attio errors
Direct Known Subclasses
ClientError, ConfigurationError, ConnectionError, ServerError
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#request_id ⇒ Object
readonly
Returns the value of attribute request_id.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
-
#initialize(message, response = nil) ⇒ Error
constructor
A new instance of Error.
Constructor Details
#initialize(message, response = nil) ⇒ Error
Returns a new instance of Error.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/attio/errors.rb', line 8 def initialize(, response = nil) @response = response if response @code = response[:status] @request_id = extract_request_id(response) # Try to extract a better error message from the response if response[:body].is_a?(Hash) = response[:body][:error] || response[:body][:message] = "#{}: #{}" if end end super() end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
6 7 8 |
# File 'lib/attio/errors.rb', line 6 def code @code end |
#request_id ⇒ Object (readonly)
Returns the value of attribute request_id.
6 7 8 |
# File 'lib/attio/errors.rb', line 6 def request_id @request_id end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
6 7 8 |
# File 'lib/attio/errors.rb', line 6 def response @response end |