From d25f6f7706026032fca1b3e3215dca12f8ec90a6 Mon Sep 17 00:00:00 2001 From: andig Date: Wed, 20 Oct 2021 15:39:11 +0200 Subject: [PATCH] Soc: match GRPC errors using values instead of type --- cmd/soc/main.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cmd/soc/main.go b/cmd/soc/main.go index ccae66c7e..0a4c78c20 100644 --- a/cmd/soc/main.go +++ b/cmd/soc/main.go @@ -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 {