final class ErrorHandlingMiddleware implements MiddlewareInterface (View source)

Translates expected HTTP failures and unexpected throwables into safe responses and error records.

Methods

__construct(Psr17Factory $responseFactory, LogManager $logs, HttpLogContext $httpLogContext, ErrorPageRenderer $errorPageRenderer, ExceptionResponseResolverInterface|null $exceptionResponseResolver = null)

Connects response rendering, error logging and an optional integration response resolver.

ResponseInterface
process(ServerRequestInterface $request, RequestHandlerInterface $handler)

Handles the request and maps exceptions without treating ordinary 404 responses as runtime errors.

ResponseInterface

Details

__construct

__construct(Psr17Factory $responseFactory, LogManager $logs, HttpLogContext $httpLogContext, ErrorPageRenderer $errorPageRenderer, ExceptionResponseResolverInterface|null $exceptionResponseResolver = null)

Connects response rendering, error logging and an optional integration response resolver.

Parameters

Psr17Factory $responseFactory
LogManager $logs
HttpLogContext $httpLogContext
ErrorPageRenderer $errorPageRenderer
ExceptionResponseResolverInterface|null $exceptionResponseResolver

process

ResponseInterface process(ServerRequestInterface $request, RequestHandlerInterface $handler)

Handles the request and maps exceptions without treating ordinary 404 responses as runtime errors.

Parameters

ServerRequestInterface $request
RequestHandlerInterface $handler

Return Value

ResponseInterface