MCPcopy
hub / github.com/stretchr/testify / NotErrorAs

Function NotErrorAs

assert/assertions.go:2245–2259  ·  view source on GitHub ↗

NotErrorAs asserts that none of the errors in err's chain matches target, but if so, sets target to that error value.

(t TestingT, err error, target interface{}, msgAndArgs ...interface{})

Source from the content-addressed store, hash-verified

2243// NotErrorAs asserts that none of the errors in err's chain matches target,
2244// but if so, sets target to that error value.
2245func NotErrorAs(t TestingT, err error, target interface{}, msgAndArgs ...interface{}) bool {
2246 if h, ok := t.(tHelper); ok {
2247 h.Helper()
2248 }
2249 if !errors.As(err, target) {
2250 return true
2251 }
2252
2253 chain := buildErrorChainString(err, true)
2254
2255 return Fail(t, fmt.Sprintf("Target error should not be in err chain:\n"+
2256 "found: %s\n"+
2257 "in chain: %s", reflect.TypeOf(target).Elem().String(), chain,
2258 ), msgAndArgs...)
2259}
2260
2261func unwrapAll(err error) (errs []error) {
2262 errs = append(errs, err)

Callers 4

NotErrorAsFunction · 0.92
NotErrorAsfFunction · 0.70
TestNotErrorAsFunction · 0.70
NotErrorAsMethod · 0.70

Calls 4

buildErrorChainStringFunction · 0.85
FailFunction · 0.70
HelperMethod · 0.65
StringMethod · 0.45

Tested by 1

TestNotErrorAsFunction · 0.56