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.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/hyper_resource/exceptions.rb', line 22 def initialize(, attrs={}) self.response = attrs[:response] self.body = attrs[:body] ## Try to help out with the message if self.body if error = self.body['error'] = "#{} (#{error})" end elsif self.response = "#{} (\"#{self.response.inspect}\")" 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.
19 20 21 |
# File 'lib/hyper_resource/exceptions.rb', line 19 def body @body end |
#response ⇒ Object
The Faraday::Response
object which led to this exception.
15 16 17 |
# File 'lib/hyper_resource/exceptions.rb', line 15 def response @response end |