Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var MaxStackDepth = 32
The maximum number of stackframes on any error.
Functions ¶
func WithStack ¶
WithStack annotates err with a skipable stack trace. If err is nil, WithStack returns nil.
It's useful when you want to create a custom error type or custom error constructor function.
skip parameter indicates how many stack frames to skip when recording the stack trace. skip = 0 means that the stack trace should begin at your current function call. skip = 1 means that the stack trace should begin at the caller of your function.
func Wrap ¶
Wrap returns an error annotating err with a skipable stack trace and the supplied message.
It's useful when you want to create a custom error type or custom error constructor function.
skip parameter indicates how many stack frames to skip when recording the stack trace. skip = 0 means that the stack trace should begin at your current function call. skip = 1 means that the stack trace should begin at the caller of your function.
func Wrapf ¶
Wrapf returns an error annotating err with a skipable stack trace and the format specifier.
It's useful when you want to create a custom error type or custom error constructor function.
skip parameter indicates how many stack frames to skip when recording the stack trace. skip = 0 means that the stack trace should begin at your current function call. skip = 1 means that the stack trace should begin at the caller of your function.
Types ¶
type StackFrame ¶
type StackFrame uintptr
StackFrame represents a program counter inside a stack frame. For historical reasons if StackFrame is interpreted as a uintptr its value represents the program counter + 1.
func (StackFrame) Format ¶
func (f StackFrame) Format(s fmt.State, verb rune)
Format formats the Stackframe according to the fmt.Formatter interface.
%s function name and source file %v function name, source file and line number
Format accepts flag "+" for %s and %v verbs for printing source file with relative path to the compile time.
func (StackFrame) Info ¶
func (f StackFrame) Info() (name string, file string, line int)
Info returns the name, file and line number for this Frame's pc.
name is the name of the function, or "unknown". file is the full path to the file that contains the function, or "unknown". line is the line number of the source code of the function.
func (StackFrame) MarshalText ¶
func (f StackFrame) MarshalText() ([]byte, error)
MarshalText formats a stacktrace Frame as a text string. The output is the same as that of fmt.Sprintf("%+v", f), but without newlines or tabs.