NotErrorIs asserts that none of the errors in err's chain matches target. This is a wrapper for errors.Is.
(t TestingT, err, target error, msgAndArgs ...interface{})
| 2196 | // NotErrorIs asserts that none of the errors in err's chain matches target. |
| 2197 | // This is a wrapper for errors.Is. |
| 2198 | func NotErrorIs(t TestingT, err, target error, msgAndArgs ...interface{}) bool { |
| 2199 | if h, ok := t.(tHelper); ok { |
| 2200 | h.Helper() |
| 2201 | } |
| 2202 | if !errors.Is(err, target) { |
| 2203 | return true |
| 2204 | } |
| 2205 | |
| 2206 | var expectedText string |
| 2207 | if target != nil { |
| 2208 | expectedText = target.Error() |
| 2209 | } |
| 2210 | |
| 2211 | chain := buildErrorChainString(err, false) |
| 2212 | |
| 2213 | return Fail(t, fmt.Sprintf("Target error should not be in err chain:\n"+ |
| 2214 | "found: %q\n"+ |
| 2215 | "in chain: %s", expectedText, chain, |
| 2216 | ), msgAndArgs...) |
| 2217 | } |
| 2218 | |
| 2219 | // ErrorAs asserts that at least one of the errors in err's chain matches target, and if so, sets target to that error value. |
| 2220 | // This is a wrapper for errors.As. |