MCPcopy Create free account
hub / github.com/cockroachdb/errors / HasInterface

Function HasInterface

markers/markers.go:128–134  ·  view source on GitHub ↗

HasInterface returns true if err contains an error which implements the interface pointed to by referenceInterface. The type of referenceInterface must be a pointer to an interface type. If referenceInterface is not a pointer to an interface, this function will panic.

(err error, referenceInterface interface{})

Source from the content-addressed store, hash-verified

126// must be a pointer to an interface type. If referenceInterface is not a
127// pointer to an interface, this function will panic.
128func HasInterface(err error, referenceInterface interface{}) bool {
129 iface := getInterfaceType("HasInterface", referenceInterface)
130 _, isType := If(err, func(err error) (interface{}, bool) {
131 return nil, reflect.TypeOf(err).Implements(iface)
132 })
133 return isType
134}
135
136func getInterfaceType(context string, referenceInterface interface{}) reflect.Type {
137 typ := reflect.TypeOf(referenceInterface)

Callers 3

HasInterfaceFunction · 0.92
ExampleHasInterfaceFunction · 0.92
TestIsInterfaceFunction · 0.92

Calls 2

getInterfaceTypeFunction · 0.85
IfFunction · 0.70

Tested by 2

ExampleHasInterfaceFunction · 0.74
TestIsInterfaceFunction · 0.74

Used in the wild real call sites across dependent graphs

searching dependent graphs…