Exception: HyperResource::ResponseError
- Defined in:
- lib/hyper_resource/exceptions.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#body ⇒ Object
The deserialized response body which led to this exception.
-
#response ⇒ Object
The
Faraday::Response
object which led to this exception.
Attributes inherited from Exception
Instance Method Summary collapse
-
#initialize(message, attrs = {}) ⇒ ResponseError
constructor
A new instance of ResponseError.
Constructor Details
#initialize(message, attrs = {}) ⇒ ResponseError
Returns a new instance of ResponseError.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/hyper_resource/exceptions.rb', line 20 def initialize(, attrs={}) # @private self.response = attrs[:response] self.body = attrs[:body] ## Try to help out with the message if body if (error = body['error']) = "#{} (#{error})" end if ( = body['message']) = "#{} (#{})" end elsif response = "#{} (#{response.body})" end super(, attrs) end |
Instance Attribute Details
#body ⇒ Object
The deserialized response body which led to this exception. May be blank, e.g. in case of deserialization errors.
18 19 20 |
# File 'lib/hyper_resource/exceptions.rb', line 18 def body @body end |
#response ⇒ Object
The Faraday::Response
object which led to this exception.
14 15 16 |
# File 'lib/hyper_resource/exceptions.rb', line 14 def response @response end |