linestory errdata

This commit is contained in:
wh_zcy 2023-06-06 15:12:20 +08:00
parent 015c649c04
commit 06b5855745
3 changed files with 12 additions and 15 deletions

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}