class CheckoutRu::Error

Attributes

code[R]

Public Class Methods

construct(response) click to toggle source
# File lib/checkout_ru/error.rb, line 4
def construct(response)
  code, message = parse_error_response(response)
  error_message = "#{message} (checkout.ru error, code #{code})"

  case code
  when 4   then NoDeliveryFoundError.new(error_message, code)
  when nil then new(response.inspect)
  else new(error_message, code)
  end
end
new(message, code = nil) click to toggle source
Calls superclass method
# File lib/checkout_ru/error.rb, line 27
def initialize(message, code = nil)
  @code = code
  super(message)
end
parse_error_response(response) click to toggle source
# File lib/checkout_ru/error.rb, line 15
def parse_error_response(response)
  if response.respond_to?(:[]) &&
    response[:error_code] &&
    response[:error_message]

    [response[:error_code], response[:error_message]]
  end
end