Friendly Message for MissingAbilityException

pull/3/head
Hasin Hayder 3 years ago
parent c670d6a2fe
commit 34e98b948b

@ -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);
}
}

Loading…
Cancel
Save