Documentation
¶
Overview ¶
Package errstack provides error wrapping with stack traces for Go.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
New creates a new error with the given message and a stack trace captured at the call site.
func Newf ¶
Newf creates a new error with a formatted message and a stack trace captured at the call site.
func StackString ¶ added in v0.2.0
StackString returns a formatted multi-line stack trace string from an error. Each frame is rendered as two lines: the function name, then the file and line indented with a tab. Returns an empty string if no stack frames are found.
func Value ¶ added in v0.2.0
Value extracts an annotation value from the error chain by key. It walks the chain using errors.As looking for an annotatedError with a matching key. Returns the value and true if found, or nil and false otherwise.
func WithValue ¶ added in v0.2.0
WithValue wraps err with a key-value annotation. The original error and its chain are preserved. Returns nil if err is nil.
Types ¶
type Frame ¶
Frame represents a single stack frame.
func Caller ¶ added in v0.2.0
Caller returns a single stack frame at the given skip depth. Skip 0 refers to the caller of Caller itself.
func Stack ¶
Stack extracts stack frames from an error. It walks the Unwrap chain looking for an error that carries stack information. Returns nil if no stack frames are found.
func TrimAbove ¶ added in v0.2.0
TrimAbove removes frames from packages above the specified package in the stack. It finds the first frame whose Function contains pkg and returns that frame and all frames below it (i.e., frames from the first occurrence onward).