Sha256: 5cc5beed0648849635e2cb9f71ca1b18d0ef0e30374f71161edd0f43369fcb59
Contents?: true
Size: 651 Bytes
Versions: 9
Compression:
Stored size: 651 Bytes
Contents
require 'faraday' require 'finix/error' module Faraday class Response::RaiseApiError < Response::Middleware HTTP_STATUS_CODES = { 400 => Finix::BadRequest, 401 => Finix::Unauthorized, 403 => Finix::Forbidden, 404 => Finix::NotFound, 405 => Finix::MethodNotAllowed, 422 => Finix::UnprocessableEntity } def on_complete(response) status_code = response[:status].to_i error_class = HTTP_STATUS_CODES[status_code] raise Finix::ResourceErrors.new(response) if error_class.nil? and status_code >= 400 raise error_class.new(response) if error_class end end end
Version data entries
9 entries across 9 versions & 1 rubygems