laravel错误

    技术2022-07-11  88

    未进行错误处理,未登录或者参数错误直接报500,做一些处理 app/Exception/Handler render方法

    if ($exception instanceof AuthenticationException ) { return response()->json([ 'status' => 401, 'message' => '未授权', 'errors' => $exception->getMessage() ], 401); } if ($exception instanceof ValidationException) { return $this->invalidJson($request, $exception); }

    这里我只处理了登录和参数问题

    Processed: 0.012, SQL: 9