Level 51
You could modify the render method in app/Exception/Handler.php
public function render($request, Exception $exception)
{
if ($exception instanceof AccessDeniedException) {
return response()->json([
'message' => 'your error message'
],401);
}
return parent::render($request, $exception);
}
Think I've got the response syntax correct from memory but you might need to check the docs
2 likes