Exception: Dato::ApiError
- Inherits:
-
StandardError
- Object
- StandardError
- Dato::ApiError
- Defined in:
- lib/dato/api_error.rb
Instance Attribute Summary collapse
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
- #body ⇒ Object
-
#initialize(response) ⇒ ApiError
constructor
A new instance of ApiError.
- #message ⇒ Object
Constructor Details
#initialize(response) ⇒ ApiError
Returns a new instance of ApiError.
7 8 9 |
# File 'lib/dato/api_error.rb', line 7 def initialize(response) @response = response end |
Instance Attribute Details
#response ⇒ Object (readonly)
Returns the value of attribute response.
5 6 7 |
# File 'lib/dato/api_error.rb', line 5 def response @response end |
Instance Method Details
#body ⇒ Object
20 21 22 23 24 |
# File 'lib/dato/api_error.rb', line 20 def body if response[:body] JSON.parse(response[:body]) end end |
#message ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/dato/api_error.rb', line 11 def [ 'DatoCMS API Error', "Status: #{response[:status]}", 'Response:', JSON.pretty_generate(body) ].join("\n") end |