Exception: Dinie::APIError

Inherits:
Error
  • Object
show all
Defined in:
lib/dinie/runtime/errors.rb,
sig/dinie/runtime/errors.rbs

Overview

Base for everything that originates from talking to the Dinie API. code / request_id are first-class on every API error.

Direct Known Subclasses

APIConnectionError, APIStatusError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message = nil, code: nil, request_id: nil) ⇒ APIError

Returns a new instance of APIError.

Parameters:

  • message (String, nil) (defaults to: nil)
  • code (String, nil) (defaults to: nil)
  • request_id (String, nil) (defaults to: nil)
  • code: (String, nil) (defaults to: nil)
  • request_id: (String, nil) (defaults to: nil)


26
27
28
29
30
# File 'lib/dinie/runtime/errors.rb', line 26

def initialize(message = nil, code: nil, request_id: nil)
  super(message)
  @code = code
  @request_id = request_id
end

Instance Attribute Details

#code ⇒ String? (readonly)

Returns machine-readable error code from the Problem Details code extension.

Returns:

  • (String, nil) —

    machine-readable error code from the Problem Details code extension



18
19
20
# File 'lib/dinie/runtime/errors.rb', line 18

def code
  @code
end

#request_id ⇒ String? (readonly)

Returns per-request correlation id (from x-request-id, body fallback).

Returns:

  • (String, nil) —

    per-request correlation id (from x-request-id, body fallback)



21
22
23
# File 'lib/dinie/runtime/errors.rb', line 21

def request_id
  @request_id
end