本章节仅介绍一些常用方法,完整的错误方法请参考接口文档:https://pkg.go.dev/github.com/gogf/gf/v2/errors/gerror
New/Newf
error
对象,并包含堆栈信息。格式:
New(text string) error Newf(format string, args ...interface{}) error |
Wrap/Wrapf
error
对象,构造成多级的错误信息,包含堆栈信息。格式:
func Wrap(err error, text string) error func Wrapf(err error, format string, args ...interface{}) error |
NewSkip/NewSkipf
error
对象,并且忽略部分堆栈信息(按照当前调用方法位置往上忽略)。高级功能,一般开发者很少用得到。格式:
func NewSkip(skip int, text string) error func NewSkipf(skip int, format string, args ...interface{}) error |
func NewCode(code int, text string) error func NewCodef(code int, format string, args ...interface{}) error func NewCodeSkip(code, skip int, text string) error func NewCodeSkipf(code, skip int, format string, args ...interface{}) error func WrapCode(code int, err error, text string) error func WrapCodef(code int, err error, format string, args ...interface{}) error |
具体介绍请参考后续 错误处理-错误码使用 章节。