Skip to content

Commit

Permalink
Merge pull request #862 from ripienaar/micro_errors
Browse files Browse the repository at this point in the history
small improvement to error handling in micro command
  • Loading branch information
ripienaar authored Sep 19, 2023
2 parents 118da2e + 5925023 commit 045de5c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions cli/micro_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"bytes"
"context"
"encoding/json"
"errors"
"fmt"
"os"
"sort"
Expand Down Expand Up @@ -177,7 +178,7 @@ func (c *microCmd) parseMessage(m []byte, expectedType string) (any, error) {
func (c *microCmd) getInstanceStats(nc *nats.Conn, name string, id string) (*micro.Stats, error) {
resp, err := doReq(nil, c.makeSubj(micro.StatsVerb, name, id), 1, nc)
if err != nil {
if err == nats.ErrNoResponders {
if errors.Is(err, nats.ErrNoResponders) {
return nil, fmt.Errorf("no micro instances found")
}
return nil, err
Expand All @@ -198,7 +199,7 @@ func (c *microCmd) getInstanceStats(nc *nats.Conn, name string, id string) (*mic
func (c *microCmd) getInfo(nc *nats.Conn, name string, id string, wait int) ([]*micro.Info, error) {
resp, err := doReq(nil, c.makeSubj(micro.InfoVerb, name, id), wait, nc)
if err != nil {
if err == nats.ErrNoResponders {
if errors.Is(err, nats.ErrNoResponders) {
return nil, fmt.Errorf("no micro instances found")
}
return nil, err
Expand Down Expand Up @@ -269,7 +270,7 @@ func (c *microCmd) statsAction(_ *fisk.ParseContext) error {

resp, err := doReq(nil, c.makeSubj(micro.StatsVerb, c.name, c.id), 0, nc)
if err != nil {
if err == nats.ErrNoResponders {
if errors.Is(err, nats.ErrNoResponders) {
return fmt.Errorf("no micro instances found")
}

Expand Down

0 comments on commit 045de5c

Please sign in to comment.