mirror of
https://github.com/flarum/core.git
synced 2025-07-17 14:51:19 +02:00
Log errors when debug mode is on too
This commit is contained in:
@@ -54,9 +54,7 @@ class FallbackExceptionHandler implements ExceptionHandlerInterface
|
|||||||
$status = 500;
|
$status = 500;
|
||||||
$error = $this->constructError($e, $status);
|
$error = $this->constructError($e, $status);
|
||||||
|
|
||||||
if (! $this->debug) {
|
|
||||||
$this->logger->error($e);
|
$this->logger->error($e);
|
||||||
}
|
|
||||||
|
|
||||||
return new ResponseBag($status, [$error]);
|
return new ResponseBag($status, [$error]);
|
||||||
}
|
}
|
||||||
|
@@ -16,10 +16,24 @@ use Psr\Http\Message\ResponseInterface as Response;
|
|||||||
use Psr\Http\Message\ServerRequestInterface as Request;
|
use Psr\Http\Message\ServerRequestInterface as Request;
|
||||||
use Psr\Http\Server\MiddlewareInterface as Middleware;
|
use Psr\Http\Server\MiddlewareInterface as Middleware;
|
||||||
use Psr\Http\Server\RequestHandlerInterface as Handler;
|
use Psr\Http\Server\RequestHandlerInterface as Handler;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
use Throwable;
|
use Throwable;
|
||||||
|
|
||||||
class HandleErrorsWithWhoops implements Middleware
|
class HandleErrorsWithWhoops implements Middleware
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @var LoggerInterface
|
||||||
|
*/
|
||||||
|
protected $logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param LoggerInterface $logger
|
||||||
|
*/
|
||||||
|
public function __construct(LoggerInterface $logger)
|
||||||
|
{
|
||||||
|
$this->logger = $logger;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Catch all errors that happen during further middleware execution.
|
* Catch all errors that happen during further middleware execution.
|
||||||
*/
|
*/
|
||||||
@@ -28,6 +42,10 @@ class HandleErrorsWithWhoops implements Middleware
|
|||||||
try {
|
try {
|
||||||
return $handler->handle($request);
|
return $handler->handle($request);
|
||||||
} catch (Throwable $e) {
|
} catch (Throwable $e) {
|
||||||
|
if ($e->getCode() !== 404) {
|
||||||
|
$this->logger->error($e);
|
||||||
|
}
|
||||||
|
|
||||||
return WhoopsRunner::handle($e, $request);
|
return WhoopsRunner::handle($e, $request);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user