class Starling::Middlewares::RaiseStarlingErrors

A Faradfay::Response::Middleware used to raise an {{Errors::ApiError}} when the Starling Bank API responds with an HTTP status code indicating an error. The raised error provides access to the response.

Constants

ERROR_STATUSES

HTTP status codes which are considered to be an error (alongside non-JSON) responses

Public Instance Methods

on_complete(env) click to toggle source

@param env The Faraday environment, providing access to the response @raise [Errors::ApiError] if the response from the Starling Bank API indicates an

error

@return [nil] if the response from the Starling Bank API doesn't indicate an

error
# File lib/starling/middlewares/raise_starling_errors.rb, line 16
def on_complete(env)
  return unless ERROR_STATUSES.include?(env.status)
  raise Errors::ApiError, env
end