Documentation ¶
Index ¶
- Constants
- func Cause(err error) error
- func Errorf(format string, args ...interface{}) error
- func From(err error, fields map[string]interface{}) error
- func FromPanic(rec interface{}) error
- func GetFields(err error) map[string]interface{}
- func GetStack(err error) string
- func New(msg string) error
- func WithStack(err error) error
- func Wrap(err error, msg string, errorFields ...map[string]interface{}) error
Constants ¶
const (
UnknownStack = "unknown"
)
Variables ¶
This section is empty.
Functions ¶
func Cause ¶
Cause returns the underlying cause of the error, if possible. An error value has a cause if it implements the following interface:
type causer interface { Cause() error }
If the error does not implement Cause, the original error will be returned. If the error is nil, nil will be returned without further investigation.
func Errorf ¶
Errorf formats according to a format specifier and returns the string as a value that satisfies error. Errorf also records the stack trace at the point it was called.
func From ¶
From returns an error annotating err with a stack trace at the point From is called, and the provided fields.
If err is nil, From returns nil.
func FromPanic ¶
func FromPanic(rec interface{}) error
FromPanic extracts the err from the result of a recover() call. If rec is not actually an error - a new error will be created, formatting the `rec` as "%s".
func GetFields ¶
GetFields returns the underlying fields of the error and its nested cause-errors, if possible. An error value has fields if it (or any of its nested cause) implements the following interface:
type fieldsProvider interface { GetFields() F }
If the error and all of its nested causes do not implement GetFields, empty fields map will be returned.
func GetStack ¶
GetStack returns the string representation of stacktrace of the provided error (see getErrorStack func for stack retrieving details).
If the provided error does not provide stack, GetStack will try to retrieve stack from its causer, then from causer of its cause, and so one.
If no stack was provided by any of the causers, the value of `UnknownStack` const will be returned.
func New ¶
New returns an error with the supplied message. New also records the stack trace at the point it was called.
func WithStack ¶
WithStack annotates err with a stack trace at the point WithStack was called. If err is nil, WithStack returns nil.
Types ¶
This section is empty.