Skip to content

Commit

Permalink
Make exceptions in one log line (#1901)
Browse files Browse the repository at this point in the history
  • Loading branch information
ildyria authored Jun 25, 2023
1 parent 94f670a commit 20da3a1
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -384,18 +384,22 @@ public function report(\Throwable $e): void
// with a higher severity than the eventual exception
$severity = self::getLogSeverity($e);

$msg = '';
do {
$cause = $this->findCause($e);
if (count($cause) === 2) {
Log::log($severity->value, $cause[1]->getMethodBeautified() . ':' . $cause[1]->getLine() . ' ' . $e->getMessage() . '; caused by');
$msg_ = $cause[1]->getMethodBeautified() . ':' . $cause[1]->getLine() . ' ' . $e->getMessage() . '; caused by';
$msg = $msg_ . PHP_EOL . $msg;
}

if ($e->getPrevious() !== null) {
Log::log($severity->value, $cause[0]->getMethodBeautified() . ':' . $cause[0]->getLine() . ' ' . $e->getMessage() . '; caused by');
$msg_ = $cause[0]->getMethodBeautified() . ':' . $cause[0]->getLine() . ' ' . $e->getMessage() . '; caused by';
} else {
Log::log($severity->value, $cause[0]->getMethodBeautified() . ':' . $cause[0]->getLine() . ' ' . $e->getMessage());
$msg_ = $cause[0]->getMethodBeautified() . ':' . $cause[0]->getLine() . ' ' . $e->getMessage();
}
$msg = $msg_ . PHP_EOL . $msg;
} while ($e = $e->getPrevious());
Log::log($severity->value, $msg);
}

/**
Expand Down

0 comments on commit 20da3a1

Please sign in to comment.