class GoCardlessPro::Error
A class to represent an API Error
Attributes
Public Class Methods
Source
# File lib/gocardless_pro/error.rb, line 8 def initialize(error) raise ArgumentError, 'GoCardless errors expect a hash' unless error.is_a?(Hash) @error = error end
intialize a new error @param error the error from the API
Public Instance Methods
Source
# File lib/gocardless_pro/error.rb, line 40 def code @error['code'] end
access the code from the response
Source
# File lib/gocardless_pro/error.rb, line 15 def documentation_url @error['documentation_url'] end
access the documentation_url
from the response
Source
# File lib/gocardless_pro/error.rb, line 50 def errors @error.fetch('errors', []) end
access the errors from the response
Source
# File lib/gocardless_pro/error.rb, line 20 def message @error['message'] end
access the message from the response
Source
# File lib/gocardless_pro/error.rb, line 45 def request_id @error['request_id'] end
access the request_id
from the response
Source
# File lib/gocardless_pro/error.rb, line 24 def to_s if errors.any? errors .map { |err| "#{err['field']} #{err['message']}" } .join(', ') else @error['message'] end end
Source
# File lib/gocardless_pro/error.rb, line 35 def type @error['type'] end
access the type from the response