Something went wrong. Try again.
Error-handling utilities missing from Go's standard library.
Something went wrong. Try again.
12345678910111213141516171819202122232425262728package uerr
import "runtime"
// WithStack records the active call stack when the error is created.// The first frame is the caller of Sentinel.New or PayloadSentinel.New.// The option may be reused; each error captures its own stack.func WithStack() ErrOption { return func(b *base) { for size := 32; ; size *= 2 { pcs := make([]uintptr, size) // Skip runtime.Callers, this option, and the sentinel's New method. n := runtime.Callers(3, pcs) if n < len(pcs) { b.stack = pcs[:n] return } } }}
// StackTrace returns the captured program counters, starting at the creation site.// It returns nil if WithStack was not used. The slice is shared with the error;// callers must not modify it. Use runtime.CallersFrames to resolve the frames.func (b *base) StackTrace() []uintptr { return b.stack}