Sha256: 0ee41e915e745c137232703eff7012017dd6a59e54fdf4b9e41e243e657c9616

Contents?: true

Size: 805 Bytes

Versions: 2

Compression:

Stored size: 805 Bytes

Contents

module TransferWise

  STATUS_CLASS_MAPPING = {
    400 => "InvalidRequestError",
    404 => "InvalidRequestError",
    401 => "AuthenticationError"
  }

  class TransferWiseError < StandardError
    attr_reader :message, :http_status, :http_body, :http_headers, :json_body

    def initialize(params = {})
      params.each do |key, value|
        instance_variable_set("@#{key}", value)
      end
    end

    def to_s
      status_string = @http_status.nil? ? "" : "(Status #{@http_status}) "
      "#{status_string}#{@message}"
    end
  end

  class APIConnectionError < TransferWiseError
  end

  class APIError < TransferWiseError
  end

  class AuthenticationError < TransferWiseError
  end

  class InvalidRequestError < TransferWiseError
  end

  class ParseError < TransferWiseError
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
transfer_wise-0.1.5 lib/transfer_wise/transfer_wise_error.rb
transfer_wise-0.1.4 lib/transfer_wise/transfer_wise_error.rb