json([ 'code'=>'4011', 'msg' => array_first(array_collapse($exception->errors()))]); } // 用户认证的异常,我们需要返回 401 的 http code 和错误信息 if ($exception instanceof UnauthorizedHttpException) { return response()->json([ 'code'=>'4012', 'msg' => $exception->getMessage()]); } //token异常 if($exception instanceof TokenBlacklistedException){ return response()->json([ 'code'=>'4013', 'msg' => $exception->getMessage()]); } // return parent::render($request, $exception); return parent::render($request, $exception); } }