Documentation ¶
Index ¶
- func As(err error, target interface{}) bool
- func Collect(cerr error, uerr ...error) error
- func Errorf(format string, args ...interface{}) error
- func Is(err, target error) bool
- func New(text string) error
- func Unwrap(err error) error
- func WithStack(err error) error
- func WithStackDepth(err error, depth int) error
- func Wrap(cerr error, uerr error) error
- func Wrapf(cerr error, msg string, args ...interface{}) error
- type Error
- type MError
- type WError
- type Warning
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Collect ¶
Collect is used to collect multiple errors. `Unwrap` is noop and `Is(err, ErrMine) == true`. While `As(err, underlyingError)` do not work, you can still get underlying errors by `MError.Cause`.
func WithStackDepth ¶
WithStackDepth is like WithStack, but can specify stack depth.
func Wrap ¶
Wrap is used to wrapping unknown errors. A typical example is that: 1. have a function `ReadMyConfig()` 2. it got errors returned from external libraries 3. you want to wrap these errors, expect `Unwrap(err) == ErrReadMyConfig && Is(err, ErrReadMyConfig) && Is(err, ErrExternalErrors)`. 4. then you are finding `err := Wrap(ErrReadMyConfig, ErrExternalErrors)` Note that wrap nil error will get nil error.
Types ¶
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error is a simple error wrapper with stacktrace.