mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-14 00:54:01 +02:00
Handle depth to avoid cases where an exception has many too many previous exceptions, fixes #1726
This commit is contained in:
@@ -153,6 +153,12 @@ class LineFormatter extends NormalizerFormatter
|
|||||||
|
|
||||||
if ($previous = $e->getPrevious()) {
|
if ($previous = $e->getPrevious()) {
|
||||||
do {
|
do {
|
||||||
|
$depth++;
|
||||||
|
if ($depth > $this->maxNormalizeDepth) {
|
||||||
|
$str .= '\n[previous exception] Over ' . $this->maxNormalizeDepth . ' levels deep, aborting normalization';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
$str .= "\n[previous exception] " . $this->formatException($previous);
|
$str .= "\n[previous exception] " . $this->formatException($previous);
|
||||||
} while ($previous = $previous->getPrevious());
|
} while ($previous = $previous->getPrevious());
|
||||||
}
|
}
|
||||||
|
@@ -198,6 +198,10 @@ class NormalizerFormatter implements FormatterInterface
|
|||||||
*/
|
*/
|
||||||
protected function normalizeException(Throwable $e, int $depth = 0)
|
protected function normalizeException(Throwable $e, int $depth = 0)
|
||||||
{
|
{
|
||||||
|
if ($depth > $this->maxNormalizeDepth) {
|
||||||
|
return ['Over ' . $this->maxNormalizeDepth . ' levels deep, aborting normalization'];
|
||||||
|
}
|
||||||
|
|
||||||
if ($e instanceof \JsonSerializable) {
|
if ($e instanceof \JsonSerializable) {
|
||||||
return (array) $e->jsonSerialize();
|
return (array) $e->jsonSerialize();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user