MCPcopy
hub / github.com/expr-lang/expr / ErrorAs

Function ErrorAs

internal/testify/assert/assertions.go:2063–2077  ·  view source on GitHub ↗

ErrorAs asserts that at least one of the errors in err's chain matches target, and if so, sets target to that error value. This is a wrapper for errors.As.

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

Source from the content-addressed store, hash-verified

2061// ErrorAs asserts that at least one of the errors in err's chain matches target, and if so, sets target to that error value.
2062// This is a wrapper for errors.As.
2063func ErrorAs(t TestingT, err error, target interface{}, msgAndArgs ...interface{}) bool {
2064 if h, ok := t.(tHelper); ok {
2065 h.Helper()
2066 }
2067 if errors.As(err, target) {
2068 return true
2069 }
2070
2071 chain := buildErrorChainString(err)
2072
2073 return Fail(t, fmt.Sprintf("Should be in error chain:\n"+
2074 "expected: %q\n"+
2075 "in chain: %s", target, chain,
2076 ), msgAndArgs...)
2077}
2078
2079func buildErrorChainString(err error) string {
2080 if err == nil {

Callers 4

ErrorAsFunction · 0.92
ErrorAsfFunction · 0.70
TestErrorAsFunction · 0.70
ErrorAsMethod · 0.70

Calls 4

buildErrorChainStringFunction · 0.85
SprintfMethod · 0.80
FailFunction · 0.70
HelperMethod · 0.45

Tested by 1

TestErrorAsFunction · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…