Class: Wepay::Middleware::CheckStatus
- Inherits:
-
Faraday::Response::Middleware
- Object
- Faraday::Response::Middleware
- Wepay::Middleware::CheckStatus
- Defined in:
- lib/wepay/middleware.rb
Overview
Checks for errors in responses from Wepay, in which case it raises a ‘Wepay::ApiError` which contains the code and the message found in the response.
Instance Method Summary collapse
Instance Method Details
#on_complete(env) ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/wepay/middleware.rb', line 32 def on_complete(env) response = env[:body] if response.is_a?(Hash) && response["error"] type = response["error"] = response["error_description"] code = response["error_code"] raise Wepay::ApiError.new(type, , code) end end |