Class: LAA::FeeCalculator::RaiseError
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- LAA::FeeCalculator::RaiseError
- Defined in:
- lib/laa/fee_calculator/raise_error.rb
Overview
Wrap Faraday adapter error handling with gem specific handlers.
Constant Summary collapse
- CLIENT_ERROR_STATUSES =
(400...600)
Instance Method Summary collapse
Instance Method Details
#on_complete(env) ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/laa/fee_calculator/raise_error.rb', line 14 def on_complete(env) case env[:status] when 400 raise LAA::FeeCalculator::ResponseError, response_values(env) when 404 raise LAA::FeeCalculator::ResourceNotFound, response_values(env) when CLIENT_ERROR_STATUSES raise LAA::FeeCalculator::ClientError, response_values(env) end end |
#response_values(env) ⇒ Object
25 26 27 |
# File 'lib/laa/fee_calculator/raise_error.rb', line 25 def response_values(env) { status: env.status, headers: env.response_headers, body: env.body } end |