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

Function ErrorContains

internal/testify/assert/assertions.go:1600–1614  ·  view source on GitHub ↗

ErrorContains asserts that a function returned an error (i.e. not `nil`) and that the error contains the specified substring. actualObj, err := SomeFunction() assert.ErrorContains(t, err, expectedErrorSubString)

(t TestingT, theError error, contains string, msgAndArgs ...interface{})

Source from the content-addressed store, hash-verified

1598// actualObj, err := SomeFunction()
1599// assert.ErrorContains(t, err, expectedErrorSubString)
1600func ErrorContains(t TestingT, theError error, contains string, msgAndArgs ...interface{}) bool {
1601 if h, ok := t.(tHelper); ok {
1602 h.Helper()
1603 }
1604 if !Error(t, theError, msgAndArgs...) {
1605 return false
1606 }
1607
1608 actual := theError.Error()
1609 if !strings.Contains(actual, contains) {
1610 return Fail(t, fmt.Sprintf("Error %#v does not contain %#v", actual, contains), msgAndArgs...)
1611 }
1612
1613 return true
1614}
1615
1616// matchRegexp return true if a specified regexp matches a string.
1617func matchRegexp(rx interface{}, str interface{}) bool {

Callers 4

ErrorContainsFunction · 0.92
ErrorContainsfFunction · 0.70
TestErrorContainsFunction · 0.70
ErrorContainsMethod · 0.70

Calls 6

SprintfMethod · 0.80
ErrorFunction · 0.70
FailFunction · 0.70
HelperMethod · 0.45
ErrorMethod · 0.45
ContainsMethod · 0.45

Tested by 1

TestErrorContainsFunction · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…