src/Middleware/Middleware/ExceptionMiddleware.php
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        try {
            $response = $handler->handle($request);
        } catch (\Throwable $exception) {
            $request = $request->withAttribute('exception', $exception);
            $response = $this->errorHandler->handle($request);
        }

        return $response;
    }
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        try {
            $response = $handler->handle($request);
        } catch (\Throwable $exception) {
            $request = $request->withAttribute('exception', $exception);
            $response = $this->errorHandler->handle($request);
        }

        return $response;
    }
Process an incoming server request and return a response, optionally delegating
to the next middleware component to create the response.

@param ServerRequestInterface $request
@param RequestHandlerInterface $handler

@return ResponseInterface