MCPcopy Index your code
hub / github.com/sourcegraph/conc / ExampleCatcher

Function ExampleCatcher

panics/panics_test.go:14–28  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

12)
13
14func ExampleCatcher() {
15 var pc Catcher
16 i := 0
17 pc.Try(func() { i += 1 })
18 pc.Try(func() { panic("abort!") })
19 pc.Try(func() { i += 1 })
20
21 rc := pc.Recovered()
22
23 fmt.Println(i)
24 fmt.Println(rc.Value.(string))
25 // Output:
26 // 2
27 // abort!
28}
29
30func ExampleCatcher_callers() {
31 var pc Catcher

Callers

nothing calls this directly

Calls 2

TryMethod · 0.95
RecoveredMethod · 0.95

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…