Exception: Veryfi::Error::VeryfiError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/veryfi/error.rb

Overview

Base class for every Veryfi SDK error.

#message returns the pretty-printed JSON error payload when one is available, otherwise the formatted "<status>" / "<status>, <error>" string. The #status and #response accessors give callers programmatic access to the same information.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message = "An error occurred", response = {}, status = nil) ⇒ VeryfiError

Returns a new instance of VeryfiError.



37
38
39
40
41
42
43
44
45
46
# File 'lib/veryfi/error.rb', line 37

def initialize(message = "An error occurred", response = {}, status = nil)
  @status = status
  @response = response
  @message = if response.nil? || response.empty?
    message
  else
    JSON.pretty_generate(response)
  end
  super(@message)
end

Instance Attribute Details

#messageObject (readonly)

Returns the value of attribute message.



35
36
37
# File 'lib/veryfi/error.rb', line 35

def message
  @message
end

#responseObject (readonly)

Returns the value of attribute response.



35
36
37
# File 'lib/veryfi/error.rb', line 35

def response
  @response
end

#statusObject (readonly)

Returns the value of attribute status.



35
36
37
# File 'lib/veryfi/error.rb', line 35

def status
  @status
end

Instance Method Details

#to_sObject



48
49
50
# File 'lib/veryfi/error.rb', line 48

def to_s
  message
end