Exception: Restify::ResponseError
- Inherits:
-
StandardError
- Object
- StandardError
- Restify::ResponseError
- Defined in:
- lib/restify/error.rb
Overview
A ResponseError is returned on a non-successful response from server. Usually it will either be a ClientError or a ServerError.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
-
#code ⇒ Fixnum
Return response status code.
-
#errors ⇒ Object
Return hash or array of errors if response included such a thing otherwise it returns nil.
-
#initialize(response) ⇒ ResponseError
constructor
A new instance of ResponseError.
-
#status ⇒ Symbol
Return response status.
Constructor Details
#initialize(response) ⇒ ResponseError
25 26 27 28 29 |
# File 'lib/restify/error.rb', line 25 def initialize(response) @response = response super "#{response.message} (#{response.code}) for `#{response.uri}':\n" \ " #{errors.inspect}" end |
Instance Attribute Details
#response ⇒ Object (readonly)
Returns the value of attribute response.
23 24 25 |
# File 'lib/restify/error.rb', line 23 def response @response end |
Instance Method Details
#code ⇒ Fixnum
Return response status code.
45 46 47 |
# File 'lib/restify/error.rb', line 45 def code response.code end |
#errors ⇒ Object
Return hash or array of errors if response included such a thing otherwise it returns nil.
52 53 54 55 56 57 58 59 60 |
# File 'lib/restify/error.rb', line 52 def errors if response.decoded_body response.decoded_body['errors'] || response.decoded_body[:errors] || response.decoded_body else response.body end end |
#status ⇒ Symbol
Return response status.
36 37 38 |
# File 'lib/restify/error.rb', line 36 def status response.status end |