Soc: match GRPC errors using values instead of type

This commit is contained in:
andig 2021-10-20 15:39:11 +02:00
parent d9c15954e6
commit d25f6f7706

View file

@ -1,7 +1,6 @@
package main
import (
"errors"
"fmt"
"log"
"math"
@ -23,6 +22,11 @@ Usage:
`)
}
// matchesError replaces errors.Is for errors returned from GRPC
func matchesError(err, match error) bool {
return strings.Contains(err.Error(), match.Error())
}
func main() {
if len(os.Args) < 3 {
usage()
@ -76,7 +80,7 @@ func main() {
var err error
start := time.Now()
for soc, err = v.SoC(); err != nil && errors.Is(err, api.ErrMustRetry); {
for soc, err = v.SoC(); err != nil && matchesError(err, api.ErrMustRetry); {
if time.Since(start) > time.Minute {
err = api.ErrTimeout
} else {