From 9a2dbaa0032d954fb190f3cf8e01aa8bb7c817b2 Mon Sep 17 00:00:00 2001 From: chenweijian <820961417@qq.com> Date: Tue, 13 Jun 2023 18:33:34 +0800 Subject: [PATCH] err --- myerr/code.go | 9 +++++++++ route/cp_r/cp_relation.go | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/myerr/code.go b/myerr/code.go index dd65707..39dd656 100755 --- a/myerr/code.go +++ b/myerr/code.go @@ -2,6 +2,7 @@ package myerr import ( "fmt" + "git.hilo.cn/hilo-common/myerr" "git.hilo.cn/hilo-common/mylogrus" "github.com/pkg/errors" "strconv" @@ -225,3 +226,11 @@ func WrapErr(err error) error { return errors.Wrap(err, "") } } + +func ToLocal(err *myerr.BusinessError) error { + return &BusinessError{ + code: err.GetCode(), + message: err.GetMsg(), + err: err.GetErr(), + } +} diff --git a/route/cp_r/cp_relation.go b/route/cp_r/cp_relation.go index 4807f3f..80253cc 100644 --- a/route/cp_r/cp_relation.go +++ b/route/cp_r/cp_relation.go @@ -156,7 +156,7 @@ func ReplyCpInvite(c *gin.Context) (*mycontext.MyContext, error) { return myCtx, err } if cpRecord == nil || cpRecord.Id == 0 { - return myCtx, msg.GetErrByLanguage(model, common.MSG_ID_ALREADY_EXPIRED, lang, comerr.AlreadyExpired) + return myCtx, myerr.ToLocal(msg.GetErrByLanguage(model, common.MSG_ID_ALREADY_EXPIRED, lang, comerr.AlreadyExpired)) } if optType == 1 { // 接受的时候 @@ -316,7 +316,7 @@ func ReplyCpCancel(c *gin.Context) (*mycontext.MyContext, error) { return myCtx, err } if cpCancel == nil || cpCancel.Id == 0 { - return myCtx, msg.GetErrByLanguage(model, common.MSG_ID_ALREADY_EXPIRED, lang, comerr.AlreadyExpired) + return myCtx, myerr.ToLocal(msg.GetErrByLanguage(model, common.MSG_ID_ALREADY_EXPIRED, lang, comerr.AlreadyExpired)) } if optType == 1 { // 撤销,只有自己能撤销自己的申请 -- 2.22.0