Skip to main content

Module error_handler

Module error_handler 

Source
Expand description

The error-handler node — turns accumulated gateway errors into a JSON error response. Typically wired to other nodes’ error ports.

§Outcome exits pass through untouched

A context that arrives with an empty ctx.errors is passed through unchanged: no template render, no status rewrite. That is the case for every outcome exit (denied, limited, broken, abort, redirect, preflight, routed, hit) — the emitting node did its job and already prepared the client-facing response, so there is no error record to report and nothing for this node to add. Without the guard, such a context would have its prepared body replaced by the raw, unsubstituted template (or by the default 500), which is precisely what the named-output-ports model exists to avoid. Outcome ports should normally be wired straight to client; routing one here is harmless but does nothing.

Structs§

ErrorHandlerPlugin
Overwrites Context.response with a configured status code and a body rendered from a template. The template may reference the most recent entry in Context.errors via {{error.code}}, {{error.message}}, and {{error.node_id}} placeholders; the content type is forced to application/json.