mirror of
https://github.com/Seldaek/monolog.git
synced 2025-10-22 17:16:18 +02:00
Better support for PHP7 \Throwable
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
namespace Monolog\Formatter;
|
||||
|
||||
use Exception;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* Encodes whatever record data is passed to it as json
|
||||
@@ -152,7 +153,7 @@ class JsonFormatter extends NormalizerFormatter
|
||||
return $normalized;
|
||||
}
|
||||
|
||||
if ($data instanceof Exception) {
|
||||
if ($data instanceof Exception || $data instanceof Throwable) {
|
||||
return $this->normalizeException($data);
|
||||
}
|
||||
|
||||
@@ -170,7 +171,7 @@ class JsonFormatter extends NormalizerFormatter
|
||||
protected function normalizeException($e)
|
||||
{
|
||||
// TODO 2.0 only check for Throwable
|
||||
if (!$e instanceof Exception && !$e instanceof \Throwable) {
|
||||
if (!$e instanceof Exception && !$e instanceof Throwable) {
|
||||
throw new \InvalidArgumentException('Exception/Throwable expected, got '.gettype($e).' / '.get_class($e));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user