mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2024-11-24 04:54:00 +00:00
6e1436cefb
Signed-off-by: Evan Lezar <elezar@nvidia.com>
20 lines
446 B
Go
20 lines
446 B
Go
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
|
|
}
|