module Afterpay::ErrorHandler
Constants
- ERRORS
Public Class Methods
inspect(response)
click to toggle source
Returns a response if request was successful, raises an error otherwise @param [Afterpay::HTTPService::Response] response @return [Afterpay::HTTPService::Response] if request was successful
# File lib/afterpay/error_handler.rb, line 11 def inspect(response) return response if response.ok? raise ERRORS[response.status].new(response_error_code(response)), response_message(response) end
response_error_code(response)
click to toggle source
# File lib/afterpay/error_handler.rb, line 21 def response_error_code(response) response.body.is_a?(String) ? JSON.parse(response.body)['errorCode'] : response.body.errorCode end
response_message(response)
click to toggle source
# File lib/afterpay/error_handler.rb, line 17 def response_message(response) response.body.is_a?(String) ? JSON.parse(response.body)['message'] : response.message end