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 ¶ added in v1.2.0
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 ¶ added in v1.3.0
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 Frame ¶
type Frame uintptr
Frame represents a program counter inside a stack frame.
func StackLevel ¶
StackLevel returns a stack from for parsing into a trace line this is primarily used by other libraries who use this package internally as the level needs to be adjusted.
func (Frame) Format ¶
Format formats the frame according to the fmt.Formatter interface.
%s source file %d source line %n function name %v equivalent to %s:%d
Format accepts flags that alter the printing of some verbs, as follows:
%+s function name and path of source file relative to the compile time GOPATH separated by \n\t (<funcname>\n\t<path>) %+v equivalent to %+s:%d
type Helper ¶ added in v1.2.0
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 string }
Link contains a single error entry, unless it's the top level error, in which case it only contains an array of errors