Exception: MasterCard::Core::Exceptions::APIException
- Inherits:
-
StandardError
- Object
- StandardError
- MasterCard::Core::Exceptions::APIException
show all
- Defined in:
- lib/mastercard/core/exceptions.rb
Overview
Instance Method Summary
collapse
Constructor Details
#initialize(message, status = nil, error_data = nil) ⇒ APIException
Base Class for all the API exceptions
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/mastercard/core/exceptions.rb', line 37
def initialize(message,status=nil, error_data=nil)
super(message)
@message = message
@status = status
@error_data = error_data
@error_code = nil
unless error_data.nil?
error_hash = Hash.new
if error_data.is_a?(Hash) && error_data.key?("Errors") && error_data["Errors"].key?("Error")
error_hash = error_data["Errors"]["Error"]
if error_hash.is_a?(Array)
error_hash = error_hash[0]
end
initDataFromHash(error_hash)
elsif error_data.is_a?(Array)
error_hash = error_data[0]
initDataFromHash(error_hash)
end
end
end
|
Instance Method Details
#describe ⇒ Object
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
# File 'lib/mastercard/core/exceptions.rb', line 88
def describe()
exception = self.class.name
exception << ": \""
exception << getMessage()
exception << "\" (status: "
exception << "%s" % getStatus()
errorCode = getErrorCode()
unless errorCode.nil?
exception << ", error code: "
exception << "%s" % getErrorCode()
end
exception << ")"
return exception
end
|
#getErrorCode ⇒ Object
80
81
82
|
# File 'lib/mastercard/core/exceptions.rb', line 80
def getErrorCode()
return @error_code
end
|
#getErrorData ⇒ Object
84
85
86
|
# File 'lib/mastercard/core/exceptions.rb', line 84
def getErrorData()
return @error_data
end
|
#getMessage ⇒ Object
72
73
74
|
# File 'lib/mastercard/core/exceptions.rb', line 72
def getMessage()
return @message
end
|
#getStatus ⇒ Object
76
77
78
|
# File 'lib/mastercard/core/exceptions.rb', line 76
def getStatus()
return @status
end
|
#to_s ⇒ Object
103
104
105
|
# File 'lib/mastercard/core/exceptions.rb', line 103
def to_s()
return '%s' % describe()
end
|