From 5c4dcaa0be76e6f3aad8dd802eefeddf52ec2ec0 Mon Sep 17 00:00:00 2001 From: "daniel.w" Date: Wed, 13 Nov 2024 12:06:40 +0800 Subject: [PATCH] update error easy func --- errs/error_code.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/errs/error_code.go b/errs/error_code.go index 7df57c3..6a9035d 100644 --- a/errs/error_code.go +++ b/errs/error_code.go @@ -1,7 +1,26 @@ package errs +import ( + "code.30cm.net/digimon/library-go/errs/code" + "fmt" + "github.com/zeromicro/go-zero/core/logx" + "strings" +) + type ErrorCode uint32 func (e ErrorCode) ToUint32() uint32 { return uint32(e) } + +func ThirdPartyError(scope uint32, ec ErrorCode, s ...string) *LibError { + return NewError(scope, code.ThirdParty, ec.ToUint32(), fmt.Sprintf("thirty error: %s", strings.Join(s, " "))) +} + +func ThirdPartyErrorL(scope uint32, ec ErrorCode, + l logx.Logger, filed []logx.LogField, s ...string) *LibError { + e := ThirdPartyError(scope, ec, s...) + l.WithCallerSkip(1).WithFields(filed...).Error(e.Error()) + + return e +}