Exception: NakoPay::APIError

Inherits:
Error
  • Object
show all
Defined in:
lib/nakopay/errors.rb

Overview

Raised for any non-2xx HTTP response.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message:, code: nil, type: nil, param: nil, doc_url: nil, request_id: nil, status_code: nil) ⇒ APIError

Returns a new instance of APIError.



9
10
11
12
13
14
15
16
17
# File 'lib/nakopay/errors.rb', line 9

def initialize(message:, code: nil, type: nil, param: nil, doc_url: nil, request_id: nil, status_code: nil)
  super(message)
  @code = code
  @type = type
  @param = param
  @doc_url = doc_url
  @request_id = request_id
  @status_code = status_code
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



7
8
9
# File 'lib/nakopay/errors.rb', line 7

def code
  @code
end

#doc_urlObject (readonly)

Returns the value of attribute doc_url.



7
8
9
# File 'lib/nakopay/errors.rb', line 7

def doc_url
  @doc_url
end

#paramObject (readonly)

Returns the value of attribute param.



7
8
9
# File 'lib/nakopay/errors.rb', line 7

def param
  @param
end

#request_idObject (readonly)

Returns the value of attribute request_id.



7
8
9
# File 'lib/nakopay/errors.rb', line 7

def request_id
  @request_id
end

#status_codeObject (readonly)

Returns the value of attribute status_code.



7
8
9
# File 'lib/nakopay/errors.rb', line 7

def status_code
  @status_code
end

#typeObject (readonly)

Returns the value of attribute type.



7
8
9
# File 'lib/nakopay/errors.rb', line 7

def type
  @type
end

Instance Method Details

#retryable?Boolean

True for 429/5xx errors that may succeed on retry.

Returns:

  • (Boolean)


20
21
22
# File 'lib/nakopay/errors.rb', line 20

def retryable?
  @status_code == 429 || (@status_code && @status_code >= 500)
end