class PayPoint::Blue::Error

Abstract error base class @abstract

Attributes

code[R]

the outcome code (e.g. +'V402'+)

response[R]

the response that caused the error

Public Class Methods

new(response) click to toggle source

Initializes the error from the response object. It uses the outcome message from the response if set.

Calls superclass method
# File lib/paypoint/blue/error.rb, line 14
def initialize(response)
  @response = response

  if outcome
    @code   = outcome[:reason_code]
    message = outcome[:reason_message]
  else
    message = "the server responded with status #{response[:status]}"
  end

  super(message)
end

Private Instance Methods

outcome() click to toggle source
# File lib/paypoint/blue/error.rb, line 29
def outcome
  @outcome ||= response[:body].is_a?(Hash) && response[:body][:outcome]
end