Skip to content

Commit

Permalink
使用caption代替prefix前缀
Browse files Browse the repository at this point in the history
  • Loading branch information
yangyile committed Aug 28, 2024
1 parent 846e269 commit 376a253
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions new_erk.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 里面
Expand Down

0 comments on commit 376a253

Please sign in to comment.