Skip to content

Commit

Permalink
Use errors.Is for error handling (#1187)
Browse files Browse the repository at this point in the history
  • Loading branch information
sashamelentyev authored Sep 28, 2021
1 parent 2e73545 commit 9a1a7ad
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion sd/consul/instancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (s *Instancer) loop(lastIndex uint64) {
index := lastIndex
instances, index, err = s.getInstances(lastIndex, s.quitc)
switch {
case err == errStopped:
case errors.Is(err, errStopped):
return // stopped via quitc
case err != nil:
s.logger.Log("err", err)
Expand Down
2 changes: 1 addition & 1 deletion transport/http/jsonrpc/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func TestServerBadEncode(t *testing.T) {
func TestServerErrorEncoder(t *testing.T) {
errTeapot := errors.New("teapot")
code := func(err error) int {
if err == errTeapot {
if errors.Is(err, errTeapot) {
return http.StatusTeapot
}
return http.StatusInternalServerError
Expand Down
2 changes: 1 addition & 1 deletion transport/http/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func TestServerBadEncode(t *testing.T) {
func TestServerErrorEncoder(t *testing.T) {
errTeapot := errors.New("teapot")
code := func(err error) int {
if err == errTeapot {
if errors.Is(err, errTeapot) {
return http.StatusTeapot
}
return http.StatusInternalServerError
Expand Down
2 changes: 1 addition & 1 deletion transport/nats/subscriber_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func TestSubscriberErrorEncoder(t *testing.T) {

errTeapot := errors.New("teapot")
code := func(err error) error {
if err == errTeapot {
if errors.Is(err, errTeapot) {
return err
}
return errors.New("dang")
Expand Down

0 comments on commit 9a1a7ad

Please sign in to comment.