Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ErrorContext ¶ added in v0.3.0
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) 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 New ¶ added in v0.2.0
func New(msg string) ErrorContext
New returns a new ErrorContext created from string
func Newf ¶ added in v0.3.0
func Newf(s string, a ...interface{}) ErrorContext
Newf returns a new ErrorContext created from format string
func Wrap ¶ added in v0.2.0
func Wrap(err error) ErrorContext
Wrap ensures supplied error is an ErrorContext, wrapping if necessary
func WrapMsg ¶ added in v0.3.0
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 ¶ added in v0.3.0
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 ¶ added in v0.3.0
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) // String returns a string representation of the ErrorData String() string }
ErrorData defines a way to set and access contextual error data. The default implementation of this is thread-safe
type KV ¶ added in v0.3.0
type KV struct { Key string Value interface{} }
KV is a structure for setting key-value pairs in ErrorData