mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2024-11-26 13:59:45 +00:00
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
|
||
|
}
|