MCPcopy Index your code
hub / github.com/maruel/panicparse / Example_simple

Function Example_simple

stack/example_test.go:168–184  ·  view source on GitHub ↗

A sample parseStack function expects a stdlib stacktrace from runtime.Stack or debug.Stack and returns the parsed stack object.

()

Source from the content-addressed store, hash-verified

166// A sample parseStack function expects a stdlib stacktrace from runtime.Stack or debug.Stack and returns
167// the parsed stack object.
168func Example_simple() {
169 parseStack := func(rawStack []byte) stack.Stack {
170 s, _, err := stack.ScanSnapshot(bytes.NewReader(rawStack), io.Discard, stack.DefaultOpts())
171 if err != nil && err != io.EOF {
172 panic(err)
173 }
174
175 if len(s.Goroutines) > 1 {
176 panic(errors.New("provided stacktrace had more than one goroutine"))
177 }
178
179 return s.Goroutines[0].Signature.Stack
180 }
181
182 parsedStack := parseStack(debug.Stack())
183 fmt.Printf("parsedStack: %#v", parsedStack)
184}
185
186// Registers a middleware to trap exceptions and report them on http.Handler.
187//

Callers

nothing calls this directly

Calls 2

ScanSnapshotFunction · 0.92
DefaultOptsFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…