Skip to content

ExceptionRenderer

Turns a caught Throwable into a client-facing PSR-7 response.

This is the seam ErrorHandlingMiddleware delegates to — it is the ONE catch point in the framework; a renderer only decides how to present what was caught, it never does its own catching.

Implementations must be worker-mode safe: no echo, no exit(), no reliance on superglobals (use $request instead — $_SERVER/$_GET can be stale or empty in a persistent worker), and must return a real PSR-7 response rather than writing output directly.

interface ExceptionRenderer

Implemented bySafeRenderer, WhoopsRenderer
Since1.0.0
SourceException/Rendering/ExceptionRenderer.php
MethodDescription
[`render(Throwable $e, ServerRequestInterface $request, int $status, stringnull $correlationId): ResponseInterface`](#render)

abstract public function render(Throwable $e, ServerRequestInterface $request, int $status, string|null $correlationId): ResponseInterface

Already-extracted correlation id, if any.

ParameterTypeDescription
$eThrowableThe caught exception (top of the chain).
$requestServerRequestInterfaceThe request that triggered it.
$statusintThe HTTP status already decided by the middleware (e.g. 400 for InvalidArgumentException, 500 default).
$correlationId`string““null`

Returns ResponseInterface