Exception: Worldline::Connect::SDK::V1::ApiException

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

Overview

Represents an error response from the Worldline Global Collect platform which contains an ID and a list of errors.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Creates a new ApiException that reports an error response from the Worldline Global Collect platform.

Parameters:

  • status_code (Integer)

    HTTP status code the response

  • response_body (String)

    HTTP response body

  • error_id (String)

    The errorId received from the Worldline Global Collect platform

  • errors (Array<Worldline::Connect::SDK::V1::Domain::APIError>)

    The errors received from the Worldline Global Collect platform

  • message (String) (defaults to: 'the Worldline Global Collect platform returned an error response')

    error message to include



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/worldline/connect/sdk/v1/api_exception.rb', line 27

def initialize(status_code, response_body, error_id, errors,
               message='the Worldline Global Collect 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)

The errorId received from the Worldline Global Collect platform if available.

Returns:

  • (String)

    the current value of error_id



18
19
20
# File 'lib/worldline/connect/sdk/v1/api_exception.rb', line 18

def error_id
  @error_id
end

#errorsArray<Worldline::Connect::SDK::V1::Domain::APIError> (readonly)

The errors received from the Worldline Global Collect platform if available; may be empty but never nil

Returns:



18
19
20
# File 'lib/worldline/connect/sdk/v1/api_exception.rb', line 18

def errors
  @errors
end

#response_bodyString (readonly)

Message body of the returned response.

Returns:

  • (String)

    the current value of response_body



18
19
20
# File 'lib/worldline/connect/sdk/v1/api_exception.rb', line 18

def response_body
  @response_body
end

#status_codeInteger (readonly)

HTTP status code of the returned response.

Returns:

  • (Integer)

    the current value of status_code



18
19
20
# File 'lib/worldline/connect/sdk/v1/api_exception.rb', line 18

def status_code
  @status_code
end

Instance Method Details

#to_sObject



45
46
47
48
49
50
51
52
53
54
# File 'lib/worldline/connect/sdk/v1/api_exception.rb', line 45

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