From 376a253c2ae5c28297c317cd8e6428f42a3a071a Mon Sep 17 00:00:00 2001 From: yangyile Date: Wed, 28 Aug 2024 21:10:12 +0700 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8caption=E4=BB=A3=E6=9B=BFpref?= =?UTF-8?q?ix=E5=89=8D=E7=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- new_erk.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/new_erk.go b/new_erk.go index ffd4426..5346cb3 100644 --- a/new_erk.go +++ b/new_erk.go @@ -3,22 +3,22 @@ package erkkratos import "github.com/go-kratos/kratos/v2/errors" // NewErkFsK 指定错误的前缀让错误打印更加简单 -func NewErkFsK(efc func(format string, args ...interface{}) *errors.Error, startWith string, middleOpt string) func(erx error) *errors.Error { +func NewErkFsK(efc func(format string, args ...interface{}) *errors.Error, caption string, middleOpt string) func(erx error) *errors.Error { return func(erx error) *errors.Error { - return efc("%s%s%s", startWith, middleOpt, erx).WithCause(erx) + return efc("%s%s%s", caption, middleOpt, erx).WithCause(erx) } } -func NewErkFsB(efc func(format string, args ...interface{}) *errors.Error, startWith string) func(erx error) *errors.Error { - return NewErkFsK(efc, startWith, " ") +func NewErkFsB(efc func(format string, args ...interface{}) *errors.Error, caption string) func(erx error) *errors.Error { + return NewErkFsK(efc, caption, " ") } -func NewErkFsC(efc func(format string, args ...interface{}) *errors.Error, startWith string) func(erx error) *errors.Error { - return NewErkFsK(efc, startWith, ":") +func NewErkFsC(efc func(format string, args ...interface{}) *errors.Error, caption string) func(erx error) *errors.Error { + return NewErkFsK(efc, caption, ":") } -func NewErkFsE(efc func(format string, args ...interface{}) *errors.Error, startWith string) func(erx error) *errors.Error { - return NewErkFsK(efc, startWith, "=") +func NewErkFsE(efc func(format string, args ...interface{}) *errors.Error, caption string) func(erx error) *errors.Error { + return NewErkFsK(efc, caption, "=") } // NewErkMtK 让错误返回的消息能够被前端直接展示,而把错误的细节放在 metadata 里面