MCPcopy Create free account
hub / github.com/sourcegraph/conc / TestRecoveredAsError

Function TestRecoveredAsError

panics/panics_test.go:146–169  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

144}
145
146func TestRecoveredAsError(t *testing.T) {
147 t.Parallel()
148 t.Run("as error is nil", func(t *testing.T) {
149 t.Parallel()
150 fn := func() error {
151 var c Catcher
152 c.Try(func() {})
153 return c.Recovered().AsError()
154 }
155 err := fn()
156 assert.Nil(t, err)
157 })
158
159 t.Run("as error is not nil nil", func(t *testing.T) {
160 t.Parallel()
161 fn := func() error {
162 var c Catcher
163 c.Try(func() { panic("oh dear!") })
164 return c.Recovered().AsError()
165 }
166 err := fn()
167 assert.NotNil(t, err)
168 })
169}

Callers

nothing calls this directly

Calls 3

TryMethod · 0.95
RecoveredMethod · 0.95
AsErrorMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…