Class: Elastomer::Client::Error

Inherits:
Error
  • Object
show all
Defined in:
lib/elastomer/client/errors.rb

Overview

General error response from client requests.

Instance Attribute Summary collapse

Instance Method Summary collapse

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
    message = Hash === response.body && response.body['error'] || response.body.to_s
  else
    message, response = response.to_s, nil
  end

  @status = response.nil? ? nil : response.status

  super message
end

Instance Attribute Details

#statusObject (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