Update error handler for L5.2

This commit is contained in:
Hillel Coren 2016-04-11 11:33:25 +03:00
parent 02670fabed
commit 245efeee2f

View File

@ -4,7 +4,11 @@ use Redirect;
use Utils; use Utils;
use Exception; use Exception;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; 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 { class Handler extends ExceptionHandler {
@ -14,7 +18,10 @@ class Handler extends ExceptionHandler {
* @var array * @var array
*/ */
protected $dontReport = [ 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) public function report(Exception $e)
{ {
// don't show these errors in the logs
if ($e instanceof HttpResponseException) {
return false;
}
if (Utils::isNinja()) { if (Utils::isNinja()) {
Utils::logError(Utils::getErrorString($e)); Utils::logError(Utils::getErrorString($e));
return false; 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 // In production, except for maintenance mode, we'll show a custom error screen
if (Utils::isNinjaProd() && !Utils::isDownForMaintenance()) { if (Utils::isNinjaProd() && !Utils::isDownForMaintenance()) {
$data = [ $data = [
@ -70,5 +85,6 @@ class Handler extends ExceptionHandler {
} else { } else {
return parent::render($request, $e); return parent::render($request, $e);
} }
*/
} }
} }