mirror of
https://github.com/flarum/core.git
synced 2025-08-07 08:56:38 +02:00
Log exceptions in error handler middleware
This commit is contained in:
@@ -13,6 +13,7 @@ namespace Flarum\Http\Middleware;
|
||||
use Franzl\Middleware\Whoops\ErrorMiddleware as WhoopsMiddleware;
|
||||
use Psr\Http\Message\ResponseInterface as Response;
|
||||
use Psr\Http\Message\ServerRequestInterface as Request;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Zend\Diactoros\Response\HtmlResponse;
|
||||
use Zend\Stratigility\ErrorMiddlewareInterface;
|
||||
|
||||
@@ -23,6 +24,11 @@ class HandleErrors implements ErrorMiddlewareInterface
|
||||
*/
|
||||
protected $templateDir;
|
||||
|
||||
/**
|
||||
* @var LoggerInterface
|
||||
*/
|
||||
protected $logger;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
@@ -30,11 +36,13 @@ class HandleErrors implements ErrorMiddlewareInterface
|
||||
|
||||
/**
|
||||
* @param string $templateDir
|
||||
* @param LoggerInterface $logger
|
||||
* @param bool $debug
|
||||
*/
|
||||
public function __construct($templateDir, $debug = false)
|
||||
public function __construct($templateDir, LoggerInterface $logger, $debug = false)
|
||||
{
|
||||
$this->templateDir = $templateDir;
|
||||
$this->logger = $logger;
|
||||
$this->debug = $debug;
|
||||
}
|
||||
|
||||
@@ -58,6 +66,9 @@ class HandleErrors implements ErrorMiddlewareInterface
|
||||
return $whoops($error, $request, $response, $out);
|
||||
}
|
||||
|
||||
// Log the exception (with trace)
|
||||
$this->logger->debug($error);
|
||||
|
||||
$errorPage = $this->getErrorPage($status);
|
||||
|
||||
return new HtmlResponse($errorPage, $status);
|
||||
|
Reference in New Issue
Block a user