Exception: MultiSafePay::RequestError

Inherits:
Exception
  • Object
show all
Defined in:
lib/multisafepay/exception.rb

Direct Known Subclasses

ResourceNotFoundError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(error, response = nil) ⇒ RequestError

Returns a new instance of RequestError.



8
9
10
11
12
13
# File 'lib/multisafepay/exception.rb', line 8

def initialize(error, response = nil)
  exception.error_code = error['error_code']
  exception.error_info  = error['error_info']

  self.response = response
end

Instance Attribute Details

#error_codeObject

Returns the value of attribute error_code.



6
7
8
# File 'lib/multisafepay/exception.rb', line 6

def error_code
  @error_code
end

#error_infoObject

Returns the value of attribute error_info.



6
7
8
# File 'lib/multisafepay/exception.rb', line 6

def error_info
  @error_info
end

Instance Method Details

#http_bodyObject



23
24
25
# File 'lib/multisafepay/exception.rb', line 23

def http_body
  response.body if response
end

#http_headersObject



19
20
21
# File 'lib/multisafepay/exception.rb', line 19

def http_headers
  response.to_hash if response
end

#to_sObject



15
16
17
# File 'lib/multisafepay/exception.rb', line 15

def to_s
  "#{error_code}: #{error_info}"
end