diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 912aaec..8fc1c4a 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -4,6 +4,7 @@ namespace App\Exceptions; use Illuminate\Database\Eloquent\ModelNotFoundException; use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; +use Laravel\Sanctum\Exceptions\MissingAbilityException; use Throwable; class Handler extends ExceptionHandler { @@ -54,6 +55,13 @@ class Handler extends ExceptionHandler { 'message'=>$exception->getMessage() ],404); } + + if ($exception instanceof MissingAbilityException) { + return response([ + 'error'=>1, + 'message'=>"Not authorized" + ],409); + } return parent::render($request, $exception); } }