MCPcopy Index your code
hub / github.com/expr-lang/expr / PanicsWithError

Function PanicsWithError

internal/testify/assert/assertions.go:1251–1266  ·  view source on GitHub ↗

PanicsWithError asserts that the code inside the specified PanicTestFunc panics, and that the recovered panic value is an error that satisfies the EqualError comparison. assert.PanicsWithError(t, "crazy error", func(){ GoCrazy() })

(t TestingT, errString string, f PanicTestFunc, msgAndArgs ...interface{})

Source from the content-addressed store, hash-verified

1249//
1250// assert.PanicsWithError(t, "crazy error", func(){ GoCrazy() })
1251func PanicsWithError(t TestingT, errString string, f PanicTestFunc, msgAndArgs ...interface{}) bool {
1252 if h, ok := t.(tHelper); ok {
1253 h.Helper()
1254 }
1255
1256 funcDidPanic, panicValue, panickedStack := didPanic(f)
1257 if !funcDidPanic {
1258 return Fail(t, fmt.Sprintf("func %#v should panic\n\tPanic value:\t%#v", f, panicValue), msgAndArgs...)
1259 }
1260 panicErr, ok := panicValue.(error)
1261 if !ok || panicErr.Error() != errString {
1262 return Fail(t, fmt.Sprintf("func %#v should panic with error message:\t%#v\n\tPanic value:\t%#v\n\tPanic stack:\t%s", f, errString, panicValue, panickedStack), msgAndArgs...)
1263 }
1264
1265 return true
1266}
1267
1268// NotPanics asserts that the code inside the specified PanicTestFunc does NOT panic.
1269//

Callers 5

PanicsWithErrorFunction · 0.92
PanicsWithErrorfFunction · 0.70
TestPanicsWithErrorFunction · 0.70
PanicsWithErrorMethod · 0.70

Calls 5

didPanicFunction · 0.85
SprintfMethod · 0.80
FailFunction · 0.70
HelperMethod · 0.45
ErrorMethod · 0.45

Tested by 2

TestPanicsWithErrorFunction · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…