From 7f1a74b5762290cb873da577f1c77299fef49cbc Mon Sep 17 00:00:00 2001 From: Gordon <1432970085@qq.com> Date: Fri, 1 Apr 2022 20:40:58 +0800 Subject: [PATCH] panic fix --- internal/api/auth/auth.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/internal/api/auth/auth.go b/internal/api/auth/auth.go index 85d427fb8..fed744d4f 100644 --- a/internal/api/auth/auth.go +++ b/internal/api/auth/auth.go @@ -35,10 +35,16 @@ func UserRegister(c *gin.Context) { etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAuthName) client := rpc.NewAuthClient(etcdConn) reply, err := client.UserRegister(context.Background(), req) - if err != nil || reply.CommonResp.ErrCode != 0 { - log.NewError(req.OperationID, "UserRegister failed ", err, reply.CommonResp.ErrCode) + if err != nil { + log.NewError(req.OperationID, "call rpc err ", err) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "internal service err"}) + return + } + if reply.CommonResp.ErrCode != 0 { + log.NewError(req.OperationID, "UserRegister failed ", err) c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": reply.CommonResp.ErrMsg}) return + } pbDataToken := &rpc.UserTokenReq{Platform: params.Platform, FromUserID: params.UserID, OperationID: params.OperationID}