From 06b5855745510fb9451bde0f6f9f90b4bb705a68 Mon Sep 17 00:00:00 2001 From: wh_zcy Date: Tue, 6 Jun 2023 15:12:20 +0800 Subject: [PATCH] linestory errdata --- modules/linestory/api_chapter.go | 4 +--- modules/linestory/api_maintask.go | 5 +---- modules/linestory/api_receive.go | 18 ++++++++++-------- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/modules/linestory/api_chapter.go b/modules/linestory/api_chapter.go index f1fa0adf7..84c6b1bd5 100644 --- a/modules/linestory/api_chapter.go +++ b/modules/linestory/api_chapter.go @@ -17,8 +17,6 @@ func (this *apiComp) Chapter(session comm.IUserSession, req *pb.LinestoryChapter TaskChapter: taskMap, } - if err := session.SendMsg(string(this.module.GetType()), LinestorySubTypeChapter, rsp); err != nil { - code = pb.ErrorCode_SystemError - } + session.SendMsg(string(this.module.GetType()), LinestorySubTypeChapter, rsp) return } diff --git a/modules/linestory/api_maintask.go b/modules/linestory/api_maintask.go index a7a95f605..ca72df7bf 100644 --- a/modules/linestory/api_maintask.go +++ b/modules/linestory/api_maintask.go @@ -31,10 +31,7 @@ func (this *apiComp) Maintask(session comm.IUserSession, req *pb.LinestoryMainta List: list, } - if err := session.SendMsg(string(this.module.GetType()), LinestorySubTypeMaintask, rsp); err != nil { - code = pb.ErrorCode_SystemError - return - } + session.SendMsg(string(this.module.GetType()), LinestorySubTypeMaintask, rsp) return } diff --git a/modules/linestory/api_receive.go b/modules/linestory/api_receive.go index 93b7f7d41..c98499272 100644 --- a/modules/linestory/api_receive.go +++ b/modules/linestory/api_receive.go @@ -29,9 +29,8 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.LinestoryReceive if conf == nil { this.module.Error("配置未找到", log.Field{Key: "uid", Value: uid}, log.Field{Key: "chapterId", Value: req.ChapterId}) errdata = &pb.ErrorData{ - Code: pb.ErrorCode_ConfigNoFound, - Title: pb.ErrorCode_ConfigNoFound.ToString(), - Message: err.Error(), + Code: pb.ErrorCode_ConfigNoFound, + Title: pb.ErrorCode_ConfigNoFound.ToString(), } return } @@ -39,7 +38,12 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.LinestoryReceive if err := this.module.modelLinestory.receive(uid, req.ChapterId); err != nil { var customErr = new(comm.CustomError) if errors.As(err, &customErr) { - code = customErr.Code + code := customErr.Code + errdata = &pb.ErrorData{ + Code: code, + Title: code.ToString(), + Message: err.Error(), + } } else { errdata = &pb.ErrorData{ Code: pb.ErrorCode_DBError, @@ -47,7 +51,7 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.LinestoryReceive Message: err.Error(), } } - this.module.Error("章节奖励领取失败", log.Field{Key: "uid", Value: uid}, log.Field{Key: "chapterId", Value: req.ChapterId}, log.Field{Key: "code", Value: code}) + this.module.Error("章节奖励领取失败", log.Field{Key: "uid", Value: uid}, log.Field{Key: "chapterId", Value: req.ChapterId}) return } @@ -63,8 +67,6 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.LinestoryReceive ChapterId: req.ChapterId, UserAssets: utils.ConvertReward(conf.Reward...), } - if err := session.SendMsg(string(this.module.GetType()), LinestorySubTypeReceive, rsp); err != nil { - code = pb.ErrorCode_SystemError - } + session.SendMsg(string(this.module.GetType()), LinestorySubTypeReceive, rsp) return }