Exception: ComplyanceSDK::Exceptions::APIError

Inherits:
SDKException
  • Object
show all
Defined in:
lib/complyance_sdk/exceptions/sdk_exception.rb

Overview

Exception raised when an API error occurs

Instance Attribute Summary collapse

Attributes inherited from SDKException

#code, #context, #suggestion

Instance Method Summary collapse

Constructor Details

#initialize(message = "API error", status_code: nil, **kwargs) ⇒ APIError

Initialize a new API error

Parameters:

  • message (String) (defaults to: "API error")

    Error message

  • status_code (Integer) (defaults to: nil)

    HTTP status code

  • kwargs (Hash)

    Additional arguments



73
74
75
76
# File 'lib/complyance_sdk/exceptions/sdk_exception.rb', line 73

def initialize(message = "API error", status_code: nil, **kwargs)
  super(message, code: :api_error, **kwargs)
  @status_code = status_code
end

Instance Attribute Details

#status_codeObject (readonly)

HTTP status code



66
67
68
# File 'lib/complyance_sdk/exceptions/sdk_exception.rb', line 66

def status_code
  @status_code
end

Instance Method Details

#error_detailHash

Get error detail (alias for context)

Returns:

  • (Hash)

    Error detail hash



81
82
83
# File 'lib/complyance_sdk/exceptions/sdk_exception.rb', line 81

def error_detail
  @context
end

#to_hHash

Convert the exception to a hash

Returns:

  • (Hash)

    The exception as a hash



88
89
90
# File 'lib/complyance_sdk/exceptions/sdk_exception.rb', line 88

def to_h
  super.merge(status_code: @status_code)
end