All Downloads are FREE. Search and download functionalities are using the official Maven repository.

php-mezzio-ph.InternalServerError.php.mustache Maven / Gradle / Ivy

There is a newer version: 7.6.0
Show newest version
responseGenerator = $responseGenerator;
    }

    /**
     * @inheritdoc
     */
    public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        $result = null;
        try {
            ErrorHandler::start();
            $result = $handler->handle($request);
            ErrorHandler::stop(true);
        }
        catch (\Throwable $error) {
            $result = $this->handleError($error);
        }
        return $result;
    }

    public function handleError(\Throwable $error): ResponseInterface
    {
        \error_log((string)$error);
        return $this->generateEmptyResponse()->withStatus(500, 'Internal server error');
    }

    protected function generateEmptyResponse(): ResponseInterface
    {
        return ($this->responseGenerator)();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy