Exception: ElvantoAPI::Error
- Inherits:
-
StandardError
- Object
- StandardError
- ElvantoAPI::Error
- Defined in:
- lib/elvanto/error.rb
Overview
Custom error class for rescuing from all API response-related ElvantoAPI errors
Direct Known Subclasses
BadRequest, InternalError, NotFound, StandardError, Unauthorized
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
Instance Method Summary collapse
-
#error_message ⇒ Sting
The error message containting in body.
-
#initialize(body = nil) ⇒ Error
constructor
A new instance of Error.
Constructor Details
#initialize(body = nil) ⇒ Error
Returns a new instance of Error.
8 9 10 11 12 13 |
# File 'lib/elvanto/error.rb', line 8 def initialize(body=nil) @body = Utils.indifferent_read_access(body) unless body.nil? super end end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
5 6 7 |
# File 'lib/elvanto/error.rb', line 5 def body @body end |
Instance Method Details
#error_message ⇒ Sting
Returns The error message containting in body.
17 18 19 20 21 22 23 |
# File 'lib/elvanto/error.rb', line 17 def set_attrs error = body.fetch('error', nil) if error error["message"] end end |