class Faraday::ErrorHandler
Public Instance Methods
call(env)
click to toggle source
# File lib/faraday/error_handler.rb, line 8 def call(env) begin response = @app.call(env) rescue Net::ReadTimeout, Errno::ETIMEDOUT, Timeout::Error, Faraday::Error::TimeoutError => e # Timeout Errors raise UTApi::ConnectionError.new(e, response_values(env)) end response.on_complete do |env| handle_return_errors(env) end end
handle_return_errors(env)
click to toggle source
# File lib/faraday/error_handler.rb, line 22 def handle_return_errors(env) case env[:status] when 302, 200, 461 # Let them pass through when 401 raise UTApi::NotLoggedInError, response_values(env) else raise UTApi::ServerError, response_values(env) end end
response_values(env)
click to toggle source
# File lib/faraday/error_handler.rb, line 33 def response_values(env) {:status => env.status, :headers => env.response_headers, :body => env.body} end