Class: Elastomer::Client::Error
Overview
General error response from client requests.
Instance Attribute Summary collapse
-
#status ⇒ Object
readonly
Returns the status code from the ‘response` or nil if the Error was not created with a response.
Instance Method Summary collapse
-
#initialize(response) ⇒ Error
constructor
Construct a new Error from the given response object or a message String.
Constructor Details
#initialize(response) ⇒ Error
Construct a new Error from the given response object or a message String. If a response object is given, the error message will be extracted from the response body.
response - Faraday::Response object or a simple error message String
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/elastomer/client/errors.rb', line 17 def initialize( response ) if response.respond_to? :body = Hash === response.body && response.body['error'] || response.body.to_s else , response = response.to_s, nil end @status = response.nil? ? nil : response.status super end |
Instance Attribute Details
#status ⇒ Object (readonly)
Returns the status code from the ‘response` or nil if the Error was not created with a response.
31 32 33 |
# File 'lib/elastomer/client/errors.rb', line 31 def status @status end |