app = $app; } public function __invoke(ServerRequestInterface $request, Throwable $exception, bool $displayErrorDetails, bool $logErrors, bool $logErrorDetails, ?LoggerInterface $logger = null) { $response = $this->app->getResponseFactory()->createResponse(); if ($exception instanceof HttpNotFoundException) { return $this->renderPage($response->withStatus(404), 'errors/404', [ 'exception' => $exception ]); } if ($exception instanceof HttpForbiddenException) { return $this->renderPage($response->withStatus(403), 'errors/403', [ 'exception' => $exception ]); } return $this->renderPage($response->withStatus(500), 'errors/500', [ 'exception' => $exception ]); } }