nvidia-container-toolkit/vendor/github.com/tsaikd/KDGoLib/errutil/util.go

20 lines
446 B
Go
Raw Permalink Normal View History

package errutil
// ContainErrorFunc check error contain error by custom equalFunc
func ContainErrorFunc(err error, equalFunc func(error) bool) bool {
errobj := castErrorObject(nil, 1, err)
contain := false
if walkerr := WalkErrors(errobj, func(errcomp ErrorObject) (stop bool, walkerr error) {
if equalFunc(errcomp) {
contain = true
return true, nil
}
return false, nil
}); walkerr != nil {
return false
}
return contain
}