Exception: Dinie::APIError

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

Overview

Base for everything that originates from talking to the Dinie API.

‘code` and `request_id` are first-class here so every API error answers them (a connection error simply carries `nil`). The extraction logic that reads them off the RFC 9457 body / response headers lives once in APIStatusError, never per marker class — mirroring the V0.2 freeze and the future generator’s “emit once into the base”.

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)


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

#codeString? (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_idString? (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