Exception: Airwallex::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/airwallex/errors.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message = nil, code: nil, param: nil, details: nil, http_status: nil) ⇒ Error

Returns a new instance of Error.



12
13
14
15
16
17
18
19
# File 'lib/airwallex/errors.rb', line 12

def initialize(message = nil, code: nil, param: nil, details: nil, http_status: nil)
  @code = code
  @message = message
  @param = param
  @details = Util.deep_symbolize_keys(details)
  @http_status = http_status
  super(message)
end

Instance Attribute Details

#codeString, ... (readonly)

Returns:

  • (String, nil)

    error code

  • (String, nil)

    param the offending field path, from the response's source

  • (Hash, Array, nil)

    details symbolized field-level error detail, e.g. from a validation_failed response (was raw/string-keyed prior to 0.8.0)

  • (Integer, nil)

    http_status



10
11
12
# File 'lib/airwallex/errors.rb', line 10

def code
  @code
end

#detailsString, ... (readonly)

Returns:

  • (String, nil)

    error code

  • (String, nil)

    param the offending field path, from the response's source

  • (Hash, Array, nil)

    details symbolized field-level error detail, e.g. from a validation_failed response (was raw/string-keyed prior to 0.8.0)

  • (Integer, nil)

    http_status



10
11
12
# File 'lib/airwallex/errors.rb', line 10

def details
  @details
end

#http_statusString, ... (readonly)

Returns:

  • (String, nil)

    error code

  • (String, nil)

    param the offending field path, from the response's source

  • (Hash, Array, nil)

    details symbolized field-level error detail, e.g. from a validation_failed response (was raw/string-keyed prior to 0.8.0)

  • (Integer, nil)

    http_status



10
11
12
# File 'lib/airwallex/errors.rb', line 10

def http_status
  @http_status
end

#messageString, ... (readonly)

Returns:

  • (String, nil)

    error code

  • (String, nil)

    param the offending field path, from the response's source

  • (Hash, Array, nil)

    details symbolized field-level error detail, e.g. from a validation_failed response (was raw/string-keyed prior to 0.8.0)

  • (Integer, nil)

    http_status



10
11
12
# File 'lib/airwallex/errors.rb', line 10

def message
  @message
end

#paramString, ... (readonly)

Returns:

  • (String, nil)

    error code

  • (String, nil)

    param the offending field path, from the response's source

  • (Hash, Array, nil)

    details symbolized field-level error detail, e.g. from a validation_failed response (was raw/string-keyed prior to 0.8.0)

  • (Integer, nil)

    http_status



10
11
12
# File 'lib/airwallex/errors.rb', line 10

def param
  @param
end

Class Method Details

.from_response(response) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/airwallex/errors.rb', line 21

def self.from_response(response)
  body = parse_body(response.body)
  status = response.status

  error_class = error_class_for_status(status)
  error_class.new(
    body["message"],
    code: body["code"],
    param: body["source"],
    details: body["details"],
    http_status: status
  )
end