Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ErrorContext ¶
type ErrorContext interface { // implement base error interface error // Is identifies whether the receiver contains / is the target Is(error) bool // Unwrap reveals the underlying wrapped error (if any!) Unwrap() error // Value attempts to fetch contextual data for given key from this ErrorContext Value(string) (interface{}, bool) // Append allows adding contextual data to this ErrorContext Append(...kv.Field) ErrorContext // Data returns the contextual data structure associated with this ErrorContext Data() ErrorData }
ErrorContext defines a wrappable error with the ability to hold extra contextual information.
func Newf ¶
func Newf(s string, a ...interface{}) ErrorContext
Newf returns a new ErrorContext created from format string.
func Wrap ¶
func Wrap(err error) ErrorContext
Wrap ensures supplied error is an ErrorContext, wrapping if necessary.
func WrapMsg ¶
func WrapMsg(err error, msg string) ErrorContext
WrapMsg wraps supplied error as inner, returning an ErrorContext with a new outer error made from the supplied message string.
func WrapMsgf ¶
func WrapMsgf(err error, msg string, a ...interface{}) ErrorContext
WrapMsgf wraps supplied error as inner, returning an ErrorContext with a new outer error made from the supplied message format string.
type ErrorData ¶
type ErrorData interface { // Value will attempt to fetch value for given key in ErrorData Value(string) (interface{}, bool) // Append adds the supplied key-values to ErrorData, similar keys DO overwrite Append(...kv.Field) }
ErrorData defines a way to set and access contextual error data. The default implementation of this is thread-safe.
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).