Class: FaradayMiddleWare::RaiseHttpException

Inherits:
Faraday::Middleware
  • Object
show all
Defined in:
lib/faraday/raise_http_exception.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ RaiseHttpException

Returns a new instance of RaiseHttpException.



5
6
7
# File 'lib/faraday/raise_http_exception.rb', line 5

def initialize(app)
  super(app)
end

Instance Method Details

#call(env) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/faraday/raise_http_exception.rb', line 9

def call(env)
  response = @app.call(env)
  response.on_complete do |_env|
    error = error_class(response.status.to_i)
    raise error.new(response) if error
  end
end