From 9ec127314140796c494a77f580fffb605c1342b7 Mon Sep 17 00:00:00 2001 From: Nabeel Shahzad Date: Sat, 30 Dec 2017 09:09:22 -0600 Subject: [PATCH] ModelNotFound exception handled #92 --- app/Exceptions/Handler.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index b5cc5676..b944e8fd 100755 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -2,6 +2,7 @@ namespace App\Exceptions; +use Illuminate\Database\Eloquent\ModelNotFoundException; use Log; use Exception; use Illuminate\Auth\AuthenticationException; @@ -58,6 +59,11 @@ class Handler extends ExceptionHandler $http_code = $exception->getStatusCode(); } + if($exception instanceof ModelNotFoundException) { + $status = 404; + $http_code = 404; + } + return response()->json([ 'error' => [ 'code' => $exception->getCode() ,