Exception: ActiveMerchant::ResponseError

Inherits:
ActiveMerchantError show all
Defined in:
lib/active_merchant/errors.rb

Overview

:nodoc:

Direct Known Subclasses

OAuthResponseError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response, message = nil) ⇒ ResponseError

Returns a new instance of ResponseError.



20
21
22
23
# File 'lib/active_merchant/errors.rb', line 20

def initialize(response, message = nil)
  @response = response
  @message  = message
end

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



18
19
20
# File 'lib/active_merchant/errors.rb', line 18

def response
  @response
end

Instance Method Details

#to_sObject



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/active_merchant/errors.rb', line 25

def to_s
  if response.kind_of?(String)
    if response.start_with?('Failed')
      return response
    else
      return "Failed with #{response}"
    end
  end

  return response.message if response.respond_to?(:message) && response.message.start_with?('Failed')

  "Failed with #{response.code if response.respond_to?(:code)} #{response.message if response.respond_to?(:message)}"
end