Class: Tango::Response::RaiseError
- Inherits:
-
Faraday::Response::Middleware
- Object
- Faraday::Response::Middleware
- Tango::Response::RaiseError
- Defined in:
- lib/tango/response/raise_error.rb
Instance Method Summary collapse
-
#initialize(app, klass) ⇒ RaiseError
constructor
A new instance of RaiseError.
- #on_complete(env) ⇒ Object
Constructor Details
#initialize(app, klass) ⇒ RaiseError
Returns a new instance of RaiseError.
13 14 15 16 |
# File 'lib/tango/response/raise_error.rb', line 13 def initialize(app, klass) @klass = klass super(app) end |
Instance Method Details
#on_complete(env) ⇒ Object
6 7 8 9 10 11 |
# File 'lib/tango/response/raise_error.rb', line 6 def on_complete(env) status_code = env[:status].to_i if @klass.raise_on?(status_code) raise @klass.from_status_code(status_code) end end |