Exception: MasterCard::Core::Exceptions::InvalidRequestException
- Inherits:
-
APIException
- Object
- StandardError
- APIException
- MasterCard::Core::Exceptions::InvalidRequestException
show all
- Defined in:
- lib/mastercard/core/exceptions.rb
Overview
Instance Method Summary
collapse
#getErrorCode, #getErrorData, #getMessage, #getStatus
Constructor Details
#initialize(message = nil, status = nil, error_data = nil) ⇒ InvalidRequestException
Exception raised when the API request contains errors.
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
|
# File 'lib/mastercard/core/exceptions.rb', line 182
def initialize(message=nil,status=nil,error_data=nil)
if status.nil?
status = 400
end
super(message,status,error_data)
@fieldErrors = []
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
initFieldDataFromHash(error_hash)
elsif error_data.is_a?(Array)
error_hash = error_data[0]
initFieldDataFromHash(error_hash)
end
end
end
|
Instance Method Details
#describe ⇒ Object
227
228
229
230
231
232
233
|
# File 'lib/mastercard/core/exceptions.rb', line 227
def describe
des = super()
@fieldErrors.each do |field_error|
des << "\n #{field_error}"
end
return des
end
|
#getFieldErrors ⇒ Object
223
224
225
|
# File 'lib/mastercard/core/exceptions.rb', line 223
def getFieldErrors
return @fieldErrors
end
|
#hasFieldErrors ⇒ Object
219
220
221
|
# File 'lib/mastercard/core/exceptions.rb', line 219
def hasFieldErrors
return @fieldErrors.length != 0
end
|
#to_s ⇒ Object
235
236
237
|
# File 'lib/mastercard/core/exceptions.rb', line 235
def to_s
return "%s"%describe()
end
|