Documentation
¶
Index ¶
- func CodeFromError(err error) mcode.Code
- func New(text string, a ...any) error
- func NewCode(code mcode.Code, text string, a ...any) error
- func Wrap(err error, text string) error
- func WrapCode(err error, code mcode.Code, text string) error
- func WrapMsg(err error, text string, a ...any) error
- type Error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewCode ¶
NewCode 创建一个带指定错误码的新错误 适用于创建一个全新的错误,并指定特定的错误码 示例:err := merror.NewCode(mcode.ValidationError, "用户名不能为空")
func Wrap ¶
Wrap 包装已有错误,保持原错误码 适用于包装底层错误,添加上下文信息,同时保留原始错误的错误码 示例:return merror.Wrap(err, "查询用户信息失败")
Types ¶
Click to show internal directories.
Click to hide internal directories.