Class: Redd::Response::RaiseError
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- Redd::Response::RaiseError
- Defined in:
- lib/redd/response/raise_error.rb
Overview
Raises the appropriate error when one comes up.
Instance Method Summary collapse
-
#call(faraday) ⇒ Object
Call the middleware.
Instance Method Details
#call(faraday) ⇒ Object
Call the middleware.
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/redd/response/raise_error.rb', line 9 def call(faraday) @app.call(faraday).on_complete do |env| if error = Redd::Error.from_response(env) if error == Redd::Error::RateLimited time = env.body[:json][:ratelimit] fail error.new(env, time) else fail error.new(env) end end end end |