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{})
| 2113 | // NotErrorIs asserts that none of the errors in err's chain matches target. |
| 2114 | // This is a wrapper for errors.Is. |
| 2115 | func NotErrorIs(t TestingT, err, target error, msgAndArgs ...interface{}) bool { |
| 2116 | if h, ok := t.(tHelper); ok { |
| 2117 | h.Helper() |
| 2118 | } |
| 2119 | if !errors.Is(err, target) { |
| 2120 | return true |
| 2121 | } |
| 2122 | |
| 2123 | var expectedText string |
| 2124 | if target != nil { |
| 2125 | expectedText = target.Error() |
| 2126 | } |
| 2127 | |
| 2128 | chain := buildErrorChainString(err) |
| 2129 | |
| 2130 | return Fail(t, fmt.Sprintf("Target error should not be in err chain:\n"+ |
| 2131 | "found: %q\n"+ |
| 2132 | "in chain: %s", expectedText, chain, |
| 2133 | ), msgAndArgs...) |
| 2134 | } |
| 2135 | |
| 2136 | // ErrorAs asserts that at least one of the errors in err's chain matches target, and if so, sets target to that error value. |
| 2137 | // This is a wrapper for errors.As. |