From 7793e90e0674b0bf04640f4864d1aa4f757b8961 Mon Sep 17 00:00:00 2001 From: KyleKatarn Date: Wed, 3 Jan 2018 22:04:06 +0100 Subject: [PATCH] Handle errors with no link to previous exception --- src/ExceptionHandlerTrait.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ExceptionHandlerTrait.php b/src/ExceptionHandlerTrait.php index 02856ae..e7837c1 100644 --- a/src/ExceptionHandlerTrait.php +++ b/src/ExceptionHandlerTrait.php @@ -29,7 +29,7 @@ public function filterErrorResponse(\Exception $exception, $request, $response) } } if (!$request->expectsJson() && $exception instanceof LocatedException) { - $className = get_class($exception->getPrevious()); + $className = get_class($exception->getPrevious() ?: $exception); $location = $exception->getLocation(); $line = $location->getLine(); $offset = $location->getOffset(); @@ -78,7 +78,7 @@ public function filterErrorResponse(\Exception $exception, $request, $response) (<\/pre>) /x', function ($match) use ($path, $line) { $code = array(); - $source = explode("\n", file_get_contents($path)); + $source = explode("\n", @file_get_contents($path)); $before = 19; $after = 7; $start = max(0, $line - $before);