Skip to content

Commit

Permalink
Merge pull request #8766 from kenjis/fix-ExceptionHandler-error-msg
Browse files Browse the repository at this point in the history
refactor: improve error message in BaseExceptionHandler
  • Loading branch information
kenjis authored Apr 12, 2024
2 parents 774cbd5 + cd6b587 commit 73ffc06
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
5 changes: 0 additions & 5 deletions phpstan-baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -4121,11 +4121,6 @@
'count' => 1,
'path' => __DIR__ . '/system/Database/Seeder.php',
];
$ignoreErrors[] = [
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Debug/BaseExceptionHandler.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Debug\\\\BaseExceptionHandler\\:\\:collectVars\\(\\) return type has no value type specified in iterable type array\\.$#',
'count' => 1,
Expand Down
10 changes: 8 additions & 2 deletions system/Debug/BaseExceptionHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,14 @@ protected static function highlightFile(string $file, int $lineNumber, int $line
*/
protected function render(Throwable $exception, int $statusCode, $viewFile = null): void
{
if (empty($viewFile) || ! is_file($viewFile)) {
echo 'The error view files were not found. Cannot render exception trace.';
if ($viewFile === null) {
echo 'The error view file was not specified. Cannot display error view.';

exit(1);
}

if (! is_file($viewFile)) {
echo 'The error view file "' . $viewFile . '" was not found. Cannot display error view.';

exit(1);
}
Expand Down

0 comments on commit 73ffc06

Please sign in to comment.