Class: Enginn::RaiseError
- Inherits:
-
Faraday::Response::RaiseError
- Object
- Faraday::Response::RaiseError
- Enginn::RaiseError
- Defined in:
- lib/enginn/error.rb
Overview
Override the Faraday::Response::RaiseError middleware to raise Enginn errors instead of Faraday’s (see github.com/lostisland/faraday -> lib/faraday/error.rb)
rubocop:disable Metrics/AbcSize rubocop:disable Metrics/CyclomaticComplexity rubocop:disable Metrics/MethodLength
Instance Method Summary collapse
Instance Method Details
#on_complete(env) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/enginn/error.rb', line 28 def on_complete(env) case env[:status] when 400 raise Enginn::BadRequestError, response_values(env) when 401 raise Enginn::UnauthorizedError, response_values(env) when 403 raise Enginn::ForbiddenError, response_values(env) when 404 raise Enginn::ResourceNotFound, response_values(env) when 407 # mimic the behavior that we get with proxy requests with HTTPS msg = %(407 "Proxy Authentication Required") raise Enginn::ProxyAuthError.new(msg, response_values(env)) when 409 raise Enginn::ConflictError, response_values(env) when 422 raise Enginn::UnprocessableEntityError, response_values(env) when ClientErrorStatuses raise Enginn::ClientError, response_values(env) when ServerErrorStatuses raise Enginn::ServerError, response_values(env) when nil raise Enginn::NilStatusError, response_values(env) end end |