Skip to content

Commit

Permalink
use errors.Is to check error
Browse files Browse the repository at this point in the history
  • Loading branch information
tonicmuroq committed Mar 3, 2021
1 parent af93a0a commit 7e20da0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ require (
github.com/golang/groupcache v0.0.0-20191027212112-611e8accdfc9 // indirect
github.com/jinzhu/configor v1.2.1
github.com/patrickmn/go-cache v2.1.0+incompatible
github.com/pkg/errors v0.9.1
github.com/projecteru2/core v0.0.0-20210302082338-f44a0e05990c
github.com/prometheus/client_golang v1.8.0
github.com/sethvargo/go-signalcontext v0.1.0
Expand Down
10 changes: 5 additions & 5 deletions selfmon/selfmon.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@ import (
"io"
"os"
"os/signal"
"strings"
"sync"
"syscall"
"time"

"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
etcdtypes "go.etcd.io/etcd/v3/clientv3"
"go.etcd.io/etcd/v3/mvcc/mvccpb"

"github.com/projecteru2/agent/types"
"github.com/projecteru2/agent/utils"
"github.com/projecteru2/core/client"
pb "github.com/projecteru2/core/rpc/gen"
coremeta "github.com/projecteru2/core/store/etcdv3/meta"

"github.com/projecteru2/agent/types"
"github.com/projecteru2/agent/utils"
coretypes "github.com/projecteru2/core/types"
)

// ActiveKey .
Expand Down Expand Up @@ -242,7 +242,7 @@ func (m *Selfmon) Register() (func(), error) {
}

if ne, un, err := m.register(); err != nil {
if !strings.Contains(err.Error(), "Key exists") {
if !errors.Is(err, coretypes.ErrKeyExists) {
log.Errorf("[Register] failed to re-register: %v", err)
time.Sleep(time.Second)
continue
Expand Down

0 comments on commit 7e20da0

Please sign in to comment.