Skip to content

Commit

Permalink
TASK: Handle non-int error codes in throwabe FileStorage
Browse files Browse the repository at this point in the history
  • Loading branch information
kdambekalns authored Nov 15, 2024
1 parent 8f2b430 commit 7760963
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Neos.Flow/Classes/Log/ThrowableStorage/FileStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,16 @@ protected function renderErrorInfo(\Throwable $error, array $additionalData = []
*/
protected function getErrorLogMessage(\Throwable $error)
{
$errorCodeNumber = ($error->getCode() > 0) ? ' #' . $error->getCode() : '';
// getCode() does not always return an integer, e.g. in PDOException it can be a string
if (is_int($error->getCode()) && $error->getCode() > 0) {
$errorCodeString = ' #' . $error->getCode();
} else {
$errorCodeString = ' [' . $error->getCode() . ']';
}
$backTrace = $error->getTrace();
$line = isset($backTrace[0]['line']) ? ' in line ' . $backTrace[0]['line'] . ' of ' . $backTrace[0]['file'] : '';

return 'Exception' . $errorCodeNumber . $line . ': ' . $error->getMessage();
return 'Exception' . $errorCodeString . $line . ': ' . $error->getMessage();
}

/**
Expand Down

0 comments on commit 7760963

Please sign in to comment.