Documentation ¶
Index ¶
- Variables
- func New(msg string, args ...any) *baseError
- func NewSentinel(typeStr, msg string) *baseError
- func NewWithType(msg, typeStr string, args ...any) *baseError
- func RecoverPanic(r interface{}, errPtr *error)
- func SentinelWithStack(err error) *baseError
- func W(err error) *baseError
- func Wrap(err error, msg string, args ...any) *baseError
- func WrapAsSentinel(err error, typeStr, msg string) *baseError
- func WrapWithType(err error, msg, typeStr string, args ...any) *baseError
- type Frame
- type Metadata
- type StackTrace
- type WrappedError
Constants ¶
This section is empty.
Variables ¶
var ( // Is reports whether any error in err's tree matches target. // // The tree consists of err itself, followed by the errors obtained by repeatedly // calling Unwrap. When err wraps multiple errors, Is examines err followed by a // depth-first traversal of its children. // // An error is considered to match a target if it is equal to that target or if // it implements a method Is(error) bool such that Is(target) returns true. // // An error type might provide an Is method so it can be treated as equivalent // to an existing error. For example, if MyError defines // // func (m MyError) Is(target error) bool { return target == fs.ErrExist } // // then Is(MyError{}, fs.ErrExist) returns true. See syscall.Errno.Is for // an example in the standard library. An Is method should only shallowly // compare err and the target and not call Unwrap on either. Is = errors.Is // As finds the first error in err's tree that matches target, and if one is found, sets // target to that error value and returns true. Otherwise, it returns false. // // The tree consists of err itself, followed by the errors obtained by repeatedly // calling Unwrap. When err wraps multiple errors, As examines err followed by a // depth-first traversal of its children. // // An error matches target if the error's concrete value is assignable to the value // pointed to by target, or if the error has a method As(interface{}) bool such that // As(target) returns true. In the latter case, the As method is responsible for // setting target. // // An error type might provide an As method so it can be treated as if it were a // different error type. // // As panics if target is not a non-nil pointer to either a type that implements // error, or to any interface type. As = errors.As )
Functions ¶
func NewSentinel ¶ added in v0.1.0
func NewSentinel(typeStr, msg string) *baseError
NewSentinel error, without a stacktrace or metadata assigned to it.
func NewWithType ¶ added in v0.0.2
NewWithType creates a new error with stacktrace and a custom type string returned by its Type() method
func RecoverPanic ¶
func RecoverPanic(r interface{}, errPtr *error)
func SentinelWithStack ¶ added in v0.0.2
func SentinelWithStack(err error) *baseError
SentinelWithStack wraps the given sentinel error. It adds a stacktrace and propagates both the type and message.
func W ¶ added in v0.0.2
func W(err error) *baseError
W wraps an error in a new error with stacktrace and propagating the metadata.
func Wrap ¶
Wrap wraps the given error in a new Error with the given message, having a stacktrace and propagating metadata.
func WrapAsSentinel ¶ added in v0.1.2
Wrap a sentinel error as another sentinel error, without a stacktrace or metadata assigned to it.
func WrapWithType ¶ added in v0.0.2
Wrap wraps the given error in a new error with stack trace and a custom type string returned by its Type() method
Types ¶
type Metadata ¶ added in v0.1.0
type Metadata map[string]interface{}
func GetMetadata ¶ added in v0.1.0
type StackTrace ¶
type StackTrace []Frame