PSR-15 Queue

ErrorMiddleware
in package
implements MiddlewareInterface

FinalYes

A PSR-15 middleware converting exceptions and errors into responses.

As recommended by PSR-15, this middleware should be the first one in the queue, so it wraps all further processing and a response is always generated.

Tags
author

Sebastian Meyer sebastian.meyer@opencultureconsulting.com

Table of Contents

Interfaces

MiddlewareInterface

Methods

__construct()  : mixed
Create a middleware converting exceptions and errors into responses.
process()  : ResponseInterface
Process an incoming server request and convert any exception or error thrown while handling it into a response.

Methods

__construct()

Create a middleware converting exceptions and errors into responses.

public __construct([callable(Throwable, ServerRequestInterface): ResponseInterface|null $errorHandler = null ][, ResponseFactoryInterface|null $responseFactory = null ]) : mixed
Parameters
$errorHandler : callable(Throwable, ServerRequestInterface): ResponseInterface|null = null

Callback converting exceptions and errors into a response (defaults to a generic error response)

$responseFactory : ResponseFactoryInterface|null = null

The PSR-17 factory creating the default error responses (defaults to Guzzle's factory, only used without custom error handler)

Tags
throws
LogicException

if a default is needed, but Guzzle is not installed

process()

Process an incoming server request and convert any exception or error thrown while handling it into a response.

public process(ServerRequestInterface $request, RequestHandlerInterface $handler) : ResponseInterface
APIYes
Parameters
$request : ServerRequestInterface

The server request to process

$handler : RequestHandlerInterface

The request handler to delegate to

Attributes
#[Override]
Return values
ResponseInterface —

The response object


        
On this page

Search results