Class: FaradayMiddleware::RaiseHttpException
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- FaradayMiddleware::RaiseHttpException
- Defined in:
- lib/faraday/raise_http_exception.rb
Overview
Raise an appropriate exception for failure HTTP response codes
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ RaiseHttpException
constructor
A new instance of RaiseHttpException.
Constructor Details
#initialize(app) ⇒ RaiseHttpException
Returns a new instance of RaiseHttpException.
14 15 16 17 |
# File 'lib/faraday/raise_http_exception.rb', line 14 def initialize(app) super app @parser = nil end |
Instance Method Details
#call(env) ⇒ Object
8 9 10 11 12 |
# File 'lib/faraday/raise_http_exception.rb', line 8 def call(env) @app.call(env).on_complete do |response| raise Judopay::APIError.factory(response) unless response.status.to_i == 200 end end |