Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Cause ¶
Cause extracts and returns the root wrapped error (the naked error with no additional information
func HasType ¶
HasType is a helper function that will recurse up from the root error and check that the provided type is present using an equality check
func RegisterHelper ¶
func RegisterHelper(helper Helper)
RegisterHelper adds a new helper function to extract Type and Tag information. errors will run all registered helpers until a match is found. NOTE helpers are run in the order they are added.
Types ¶
type Chain ¶
type Chain []*Link
Chain contains the chained errors, the links, of the chains if you will
func New ¶
New creates an error with the provided text and automatically wraps it with line information.
func Newf ¶
Newf creates an error with the provided text and automatically wraps it with line information. it also accepts a varadic for optional message formatting.
func Wrap ¶
Wrap encapsulates the error, stores a contextual prefix and automatically obtains a stack trace.
func WrapSkipFrames ¶
WrapSkipFrames is a special version of Wrap that skips extra n frames when determining error location. Normally only used when wrapping the library
func Wrapf ¶
Wrapf encapsulates the error, stores a contextual prefix and automatically obtains a stack trace. it also accepts a varadic for prefix formatting.
type Helper ¶
Helper is a function which will automatically extract Type and Tag information based on the supplied err and add it to the supplied *Link error; this can be used independently or by registering using errors.RegisterHelper(...), which will run the registered helper every time errors.Wrap(...) is called.
type Link ¶
type Link struct { // Err is the wrapped error, either the original or already wrapped Err error // Prefix contains the error prefix text Prefix string // Type stores one or more categorized types of error set by the caller using AddTypes and is optional Types []string // Tags contains an array of tags associated with this error, if any Tags []Tag // Source contains the name, file and lines obtained from the stack trace Source runtimeext.Frame }
Link contains a single error entry, unless it's the top level error, in which case it only contains an array of errors