MCPcopy Index your code
hub / github.com/pkg/errors / Example_stackTrace

Function Example_stackTrace

example_test.go:175–193  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

173}
174
175func Example_stackTrace() {
176 type stackTracer interface {
177 StackTrace() errors.StackTrace
178 }
179
180 err, ok := errors.Cause(fn()).(stackTracer)
181 if !ok {
182 panic("oops, err does not implement stackTracer")
183 }
184
185 st := err.StackTrace()
186 fmt.Printf("%+v", st[0:2]) // top two frames
187
188 // Example output:
189 // github.com/pkg/errors_test.fn
190 // /home/dfc/src/github.com/pkg/errors/example_test.go:47
191 // github.com/pkg/errors_test.Example_stackTrace
192 // /home/dfc/src/github.com/pkg/errors/example_test.go:127
193}
194
195func ExampleCause_printf() {
196 err := errors.Wrap(func() error {

Callers

nothing calls this directly

Calls 3

fnFunction · 0.85
CauseMethod · 0.65
StackTraceMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…