Class: Common::Client::Middleware::Response::GIDSErrors
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- Common::Client::Middleware::Response::GIDSErrors
- Defined in:
- lib/common/client/middleware/response/gids_errors.rb
Instance Method Summary collapse
-
#on_complete(env) ⇒ Object
TODO: Consider consolidating this with caseflow_errors middleware into a common json_api_errors middleware.
Instance Method Details
#on_complete(env) ⇒ Object
TODO: Consider consolidating this with caseflow_errors middleware into a common json_api_errors middleware
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/common/client/middleware/response/gids_errors.rb', line 10 def on_complete(env) return if env.success? mapped_error = env[:body]['errors']&.first return if mapped_error.nil? # GIDS does not generally populate a "code" so we # fall back to using the status as a code. env[:body]['code'] = mapped_error['code'] || mapped_error['status'] env[:body]['detail'] = mapped_error['title'] env[:body]['source'] = mapped_error['detail'] end |