Class: Faraday::Response::RaiseError

Inherits:
Middleware show all
Defined in:
lib/faraday/response/raise_error.rb

Instance Method Summary (collapse)

Methods inherited from Middleware

#call

Methods inherited from Middleware

dependency, #initialize, loaded?, setup_parallel_manager

Constructor Details

This class inherits a constructor from Faraday::Middleware

Instance Method Details

- (Object) on_complete(env)



3
4
5
6
7
8
9
10
# File 'lib/faraday/response/raise_error.rb', line 3

def on_complete(env)
  case env[:status]
  when 404
    raise Faraday::Error::ResourceNotFound, response_values(env)
  when 400...600
    raise Faraday::Error::ClientError, response_values(env)
  end
end

- (Object) response_values(env)



12
13
14
# File 'lib/faraday/response/raise_error.rb', line 12

def response_values(env)
  {:status => env[:status], :headers => env[:response_headers], :body => env[:body]}
end