Exception: Ingenico::Connect::SDK::ApiException

Inherits:
RuntimeError
  • Object
show all
Defined in:
lib/ingenico/connect/sdk/api_exception.rb

Overview

Base class for many exceptions raised by the SDK. It is raised when an error response is received from the Ingenico ePayments platform. It contains data about the returned response.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status_code, response_body, error_id, errors, message = 'the Ingenico ePayments platform returned an error response') ⇒ ApiException

Creates a new ApiException that reports an error response from the Ingenico ePayments platform.



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/ingenico/connect/sdk/api_exception.rb', line 22

def initialize(status_code, response_body, error_id, errors,
               message = 'the Ingenico ePayments platform returned an error response')
  super(message)
  @status_code = status_code
  @response_body = response_body
  @error_id = error_id
  if errors.nil?
    @errors = [].freeze
  else
    @errors = errors
  end
end

Instance Attribute Details

#error_idString (readonly)

An error id corresponding to the error that occurred, if available.



13
14
15
# File 'lib/ingenico/connect/sdk/api_exception.rb', line 13

def error_id
  @error_id
end

#errorsArray<Ingenico::Connect::SDK::Domain::Errors::APIError> (readonly)

A list of errors received from the Ingenico ePayments platform; may be empty but never nil



13
14
15
# File 'lib/ingenico/connect/sdk/api_exception.rb', line 13

def errors
  @errors
end

#response_bodyString (readonly)

Message body of the returned response.



13
14
15
# File 'lib/ingenico/connect/sdk/api_exception.rb', line 13

def response_body
  @response_body
end

#status_codeInteger (readonly)

HTTP status code of the returned response.



13
14
15
# File 'lib/ingenico/connect/sdk/api_exception.rb', line 13

def status_code
  @status_code
end

Instance Method Details

#to_sObject



40
41
42
43
44
45
46
47
48
49
# File 'lib/ingenico/connect/sdk/api_exception.rb', line 40

def to_s
  str = super.to_s
  if @status_code > 0
    str += '; status_code=' + @status_code.to_s
  end
  if !@response_body.nil? && @response_body.length > 0
    str += "; response_body='" + @response_body + "'"
  end
  str.to_s
end