Sha256: 99057803996eeba86c1cb6ec4e07efabe7e67d4268a2b7226e23d7e431f73552

Contents?: true

Size: 418 Bytes

Versions: 3

Compression:

Stored size: 418 Bytes

Contents

require 'faraday'
require_relative '../errors'

module Faraday

  class Response::RaiseApiError < Response::Middleware
    def on_complete(response)
      status_code = response[:status].to_i
      error_class = Finix.errors_registry[status_code]
      raise Finix.errors_registry[:unknown].new response if error_class.nil? and status_code >= 400
      raise error_class.new response if error_class
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
finix-1.0.1 lib/finix/response/finix_error_middleware.rb
finix-1.0.0 lib/finix/response/finix_error_middleware.rb
finix-0.16 lib/finix/response/finix_error_middleware.rb