From 245efeee2ff86b8fa0ffccd1c547823e0f20cee2 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Mon, 11 Apr 2016 11:33:25 +0300 Subject: [PATCH] Update error handler for L5.2 --- app/Exceptions/Handler.php | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 9d17fb0990..76b2087ad8 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -4,7 +4,11 @@ use Redirect; use Utils; use Exception; use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; -use Illuminate\Database\Eloquent\ModelNotFoundException; +use Illuminate\Http\Exception\HttpResponseException; +use Illuminate\Auth\Access\AuthorizationException; +use Illuminate\Database\Eloquent\ModelNotFoundException; +use Symfony\Component\HttpKernel\Exception\HttpException; +use Illuminate\Foundation\Validation\ValidationException; class Handler extends ExceptionHandler { @@ -14,7 +18,10 @@ class Handler extends ExceptionHandler { * @var array */ protected $dontReport = [ - 'Symfony\Component\HttpKernel\Exception\HttpException' + AuthorizationException::class, + HttpException::class, + ModelNotFoundException::class, + ValidationException::class, ]; /** @@ -27,6 +34,11 @@ class Handler extends ExceptionHandler { */ public function report(Exception $e) { + // don't show these errors in the logs + if ($e instanceof HttpResponseException) { + return false; + } + if (Utils::isNinja()) { Utils::logError(Utils::getErrorString($e)); return false; @@ -59,6 +71,9 @@ class Handler extends ExceptionHandler { } } + return parent::render($request, $e); + + /* // In production, except for maintenance mode, we'll show a custom error screen if (Utils::isNinjaProd() && !Utils::isDownForMaintenance()) { $data = [ @@ -70,5 +85,6 @@ class Handler extends ExceptionHandler { } else { return parent::render($request, $e); } + */ } }