Skip to main content

Module problem

Module problem 

Source
Expand description

RFC 9457 “Problem Details for HTTP APIs”.

ProblemDetails is the wire format for CqrsError when the problem-json feature is enabled: responses are served as application/problem+json with the standard members (type, title, status, detail, instance) plus the CQRS-specific extension members (domain, code, internalCode, details, requestId).

{
  "type": "urn:cqrs-error:account:ACCOUNT_INSUFFICIENT_FUNDS",
  "title": "ACCOUNT_INSUFFICIENT_FUNDS",
  "status": 400,
  "detail": "Cannot withdraw 500, balance is 200",
  "instance": "urn:cqrs-request:req-123",
  "domain": "account",
  "code": "ACCOUNT_INSUFFICIENT_FUNDS",
  "internalCode": 10001,
  "requestId": "req-123"
}

The conversion is always available, even without the feature, so an application can render problem documents on its own routes.

Structs§

ProblemDetails
An RFC 9457 problem document.

Constants§

PROBLEM_JSON
Media type of a problem document (RFC 9457 §3).

Functions§

problem_type_base_uri
Returns the configured base URI, if any.
set_problem_type_base_uri
Sets the base URI used to build the type member of problem documents: the resulting URI is {base}/{code} (e.g. https://api.example.com/errors/ACCOUNT_INSUFFICIENT_FUNDS).