Skip to content

Commit

Permalink
fix: fix error when exception has no previous exception
Browse files Browse the repository at this point in the history
  • Loading branch information
EdieLemoine committed Jul 11, 2024
1 parent 5a3d517 commit 0c5c1ad
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions myparcelnl.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,17 +218,22 @@ private function withErrorHandling(
if ($this->hasPdk) {
$previous = $e->getPrevious();

Logger::error($e->getMessage(), [
'file' => $e->getFile(),
'line' => $e->getLine(),
'trace' => $e->getTrace(),
'previous' => [
$context = [
'file' => $e->getFile(),
'line' => $e->getLine(),
'trace' => $e->getTrace(),
];

if ($previous) {
$context['previous'] = [
'message' => $previous->getMessage(),
'file' => $previous->getFile(),
'line' => $previous->getLine(),
'trace' => $previous->getTrace(),
],
]);
];
}

Logger::error($e->getMessage(), $context);
}

$formattedMessage = sprintf(
Expand Down

0 comments on commit 0c5c1ad

Please sign in to comment.