Soc: match GRPC errors using values instead of type
This commit is contained in:
parent
d9c15954e6
commit
d25f6f7706
1 changed files with 6 additions and 2 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue