Documentation
¶
Overview ¶
Package errors provides simple functions to manipulate errors.
Very note that, this package is quite a base package, which should not import extra packages except standard packages, to avoid cycle imports.
Index ¶
- func Cause(err error) error
- func Code(err error) int
- func Current(err error) error
- func New(text string) error
- func NewCode(code int, text string) error
- func NewCodeSkip(code, skip int, text string) error
- func NewCodeSkipf(code, skip int, format string, args ...interface{}) error
- func NewCodef(code int, format string, args ...interface{}) error
- func NewSkip(skip int, text string) error
- func NewSkipf(skip int, format string, args ...interface{}) error
- func Newf(format string, args ...interface{}) error
- func Next(err error) error
- func Stack(err error) string
- func Wrap(err error, text string) error
- func WrapCode(code int, err error, text string) error
- func WrapCodef(code int, err error, format string, args ...interface{}) error
- func Wrapf(err error, format string, args ...interface{}) error
- type Error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Code ¶ added in v1.14.6
Cause returns the error code of current error. It returns -1 if it has no error code or it does not implements interface Code.
func Current ¶ added in v1.14.0
Current creates and returns the current level error. It returns nil if current level error is nil.
func NewCode ¶ added in v1.14.6
NewCode creates and returns an error that has error code and given text.
func NewCodeSkip ¶ added in v1.14.6
NewCodeSkip creates and returns an error which has error code and is formatted from given text. The parameter <skip> specifies the stack callers skipped amount.
func NewCodeSkipf ¶ added in v1.14.6
NewCodeSkipf returns an error that has error code and formats as the given format and args. The parameter <skip> specifies the stack callers skipped amount.
func NewCodef ¶ added in v1.14.6
NewCodef returns an error that has error code and formats as the given format and args.
func NewSkip ¶ added in v1.12.3
NewSkip creates and returns an error which is formatted from given text. The parameter <skip> specifies the stack callers skipped amount.
func NewSkipf ¶ added in v1.14.6
NewSkipf returns an error that formats as the given format and args. The parameter <skip> specifies the stack callers skipped amount.
func Next ¶ added in v1.14.0
Next returns the next level error. It returns nil if current level error or the next level error is nil.
func Stack ¶
Stack returns the stack callers as string. It returns an empty string if the <err> does not support stacks.
func WrapCode ¶ added in v1.14.6
WrapCode wraps error with code and text. It returns nil if given err is nil.
Types ¶
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error is custom error for additional features.
func (*Error) Code ¶ added in v1.14.6
Code returns the error code. It returns -1 if it has no error code.
func (*Error) Current ¶ added in v1.14.0
Current creates and returns the current level error. It returns nil if current level error is nil.
func (*Error) Format ¶
Format formats the frame according to the fmt.Formatter interface.
%v, %s : Print all the error string; %-v, %-s : Print current level error string; %+s : Print full stack error list; %+v : Print the error string and full stack error list;