module ShieldPay::Errors

Constants

ERROR_MATCHING

Public Instance Methods

check_for_error(response_body) click to toggle source
# File lib/shieldpay/errors.rb, line 37
def check_for_error(response_body)
  user_message = response_body['coreRes']['userMessage']
  raise_error(user_message) if has_error?(response_body)
end

Private Instance Methods

has_error?(response_body) click to toggle source
# File lib/shieldpay/errors.rb, line 44
def has_error?(response_body)
  response_body['coreRes']['status'].to_i != 1
end
raise_error(user_message) click to toggle source
# File lib/shieldpay/errors.rb, line 48
def raise_error(user_message)
  error_klass = ERROR_MATCHING[user_message] || OtherShieldPayError

  raise error_klass.new(user_message)
end