ModelNotFound exception handled #92
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Exceptions;
|
namespace App\Exceptions;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||||
use Log;
|
use Log;
|
||||||
use Exception;
|
use Exception;
|
||||||
use Illuminate\Auth\AuthenticationException;
|
use Illuminate\Auth\AuthenticationException;
|
||||||
@@ -58,6 +59,11 @@ class Handler extends ExceptionHandler
|
|||||||
$http_code = $exception->getStatusCode();
|
$http_code = $exception->getStatusCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($exception instanceof ModelNotFoundException) {
|
||||||
|
$status = 404;
|
||||||
|
$http_code = 404;
|
||||||
|
}
|
||||||
|
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'error' => [
|
'error' => [
|
||||||
'code' => $exception->getCode() ,
|
'code' => $exception->getCode() ,
|
||||||
|
|||||||
Reference in New Issue
Block a user