fix error type comparison

This commit is contained in:
Shrenuj Bansal 2022-08-18 17:55:56 -04:00
parent 00975237b1
commit 7c404d8b5e

View File

@ -2,6 +2,7 @@ package retry
import (
"errors"
"reflect"
"time"
logging "github.com/ipfs/go-log/v2"
@ -11,8 +12,8 @@ var log = logging.Logger("retry")
func errorIsIn(err error, errorTypes []error) bool {
for _, etype := range errorTypes {
tmp := etype
if errors.As(err, &tmp) {
tmp := reflect.New(reflect.PointerTo(reflect.ValueOf(etype).Elem().Type())).Interface()
if errors.As(err, tmp) {
return true
}
}