class FaradayMiddleware::CloseioErrorHandler

Constants

ERROR_STATUSES

Public Instance Methods

on_complete(env) click to toggle source
# File lib/closeio/error.rb, line 13
def on_complete(env)
  case env[:status]
  when 401
    raise Closeio::NotAuthorized, env.body
  when 404
    raise Closeio::NotFound, env.body
  when 429
    raise Closeio::TooManyRequests, env.body
  when 504
    raise Closeio::GatewayTimeout, env.body
  when ERROR_STATUSES
    raise Closeio::Error, "#{env.status}: #{env.body}"
  end
end