Exception: SpyriApi::Error
- Inherits:
-
StandardError
- Object
- StandardError
- SpyriApi::Error
- Defined in:
- lib/spyri_api/error.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#details ⇒ Object
readonly
Returns the value of attribute details.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
-
#initialize(status, body) ⇒ Error
constructor
A new instance of Error.
- #inspect ⇒ Object
Constructor Details
#initialize(status, body) ⇒ Error
Returns a new instance of Error.
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/spyri_api/error.rb', line 8 def initialize(status, body) @status = status if @status == 404 @code = 'not_found' else data = JSON.parse(body) @code = data['code'] @details = data['details'] end super @code end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
6 7 8 |
# File 'lib/spyri_api/error.rb', line 6 def code @code end |
#details ⇒ Object (readonly)
Returns the value of attribute details.
6 7 8 |
# File 'lib/spyri_api/error.rb', line 6 def details @details end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
6 7 8 |
# File 'lib/spyri_api/error.rb', line 6 def status @status end |
Instance Method Details
#inspect ⇒ Object
20 21 22 |
# File 'lib/spyri_api/error.rb', line 20 def inspect "<#{self.class}: #{instance_variables.map { |v| "#{v}=#{instance_variable_get(v)}"}.join(', ')}>" end |