Expand description
Canonical error middleware (DESIGN.md §3.2 / §3.6 / §3.7).
Post-processes responses with Content-Type: application/problem+json,
filling missing trace_id (W3C traceparent → x-trace-id →
x-request-id → span-id fallback) and instance (request URI path).
Logs at warn! for 4xx / error! for 5xx with structured fields.
Catch-all behaviour (panics, unknown error types) is out of scope per
PRD §4.2 — CatchPanicLayer handles panics; handlers are responsible
for typing their errors as CanonicalError.
Functions§
- canonical_
error_ middleware - Tower middleware function that fills
trace_id/instanceon canonical Problem responses and logs atwarn!(4xx) /error!(5xx).