ModelNotFound exception handled #92

This commit is contained in:
Nabeel Shahzad 2017-12-30 09:09:22 -06:00
parent 2ee655b9d1
commit 9ec1273141

View File

@ -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() ,