Class: Wayback::Response::RaiseError
- Inherits:
-
Faraday::Response::Middleware
- Object
- Faraday::Response::Middleware
- Wayback::Response::RaiseError
- Defined in:
- lib/wayback/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.
24 25 26 27 |
# File 'lib/wayback/response/raise_error.rb', line 24 def initialize(app, klass) @klass = klass super(app) end |
Instance Method Details
#on_complete(env) ⇒ Object
18 19 20 21 22 |
# File 'lib/wayback/response/raise_error.rb', line 18 def on_complete(env) status_code = env[:status].to_i error_class = @klass.errors[status_code] raise error_class.from_response(env) if error_class end |