Class: FinAppsCore::Middleware::RaiseError

Inherits:
Faraday::Response::Middleware
  • Object
show all
Defined in:
lib/finapps_core/middleware/response/raise_error.rb

Overview

:nodoc:

Constant Summary collapse

SUCCESS_STATUSES =
(200..299).freeze
API_UNAUTHENTICATED =
401
FORBIDDEN =
403
CONNECTION_FAILED_STATUS =
407
API_SESSION_TIMEOUT =
419
LOCKOUT_MESSAGE =
'account is locked'

Instance Method Summary collapse

Instance Method Details

#on_complete(env) ⇒ Object



16
17
18
19
20
# File 'lib/finapps_core/middleware/response/raise_error.rb', line 16

def on_complete(env)
  return if SUCCESS_STATUSES.include?(env[:status])

  failures env
end

#response_values(env) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/finapps_core/middleware/response/raise_error.rb', line 22

def response_values(env)
  {
    status: env.status,
    headers: env.response_headers,
    body: env.body,
    error_messages: error_messages(env.body)
  }
end