Documentation ¶
Index ¶
- Constants
- func As(err error, target any) bool
- func AsV2[Type any](err error) Type
- func Is(err error, target error) bool
- func IsV2(err error, targets ...error) bool
- func Join(errs ...error) error
- func New(msg string) error
- func NewAt(skip int, msg string) error
- func Newf(msgf string, args ...interface{}) error
- func Unwrap(err error) error
- func UnwrapV2(err error) []error
- func Value(err error, key any) any
- func WithValue(err error, key any, value any) error
- func Wrap(err error, msg string) error
- func WrapAt(skip int, err error, msg string) error
- func Wrapf(err error, msgf string, args ...interface{}) error
- type Callers
- type OnceError
Constants ¶
const IncludesCaller = false
IncludesCaller is a compile-time flag used to indicate whether to include calling function prefix on error wrap / creation.
const IncludesStacktrace = false
IncludesStacktrace is a compile-time flag used to indicate whether to include stacktraces on error wrap / creation.
Variables ¶
This section is empty.
Functions ¶
func AsV2 ¶ added in v2.3.1
AsV2 is functionally similar to As(), instead leveraging generics to handle allocation and returning of a concrete generic parameter type.
func New ¶
New returns a new error created from message.
Note this function cannot be inlined, to ensure expected and consistent behaviour in setting trace / caller info.
func NewAt ¶ added in v2.3.0
NewAt returns a new error created, skipping 'skip' frames for trace / caller information, from message.
Note this function cannot be inlined, to ensure expected and consistent behaviour in setting trace / caller info.
func Newf ¶
Newf returns a new error created from message format and args.
Note this function cannot be inlined, to ensure expected and consistent behaviour in setting trace / caller info.
func UnwrapV2 ¶ added in v2.3.1
UnwrapV2 is functionally similar to Unwrap(), except that it also handles the case of interface{ Unwrap() []error }.
func WithValue ¶ added in v2.1.0
WithValue wraps err to store given key-value pair, accessible via Value() function.
func Wrap ¶
Wrap will wrap supplied error within a new error created from message.
Note this function cannot be inlined, to ensure expected and consistent behaviour in setting trace / caller info.
Types ¶
type Callers ¶
Callers ...
func Stacktrace ¶
Stacktrace fetches first stored stacktrace of callers from error chain.
func (Callers) MarshalJSON ¶
MarshalJSON implements json.Marshaler to provide an easy, simple default.
type OnceError ¶
type OnceError struct {
// contains filtered or unexported fields
}
OnceError is an error structure that supports safe multi threaded usage and setting only once (until reset).