Skip to content

Commit

Permalink
Merge pull request #1075 from scrtlabs/lior-correct-error-in-label
Browse files Browse the repository at this point in the history
Correct the error in label cli
  • Loading branch information
liorbond authored Aug 23, 2022
2 parents 7b04756 + 1c74bcf commit 382ceac
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion x/compute/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"fmt"
"io/ioutil"
"strconv"
"strings"

"github.com/gogo/protobuf/proto"

Expand Down Expand Up @@ -96,7 +97,11 @@ func GetCmdQueryLabel() *cobra.Command {
route := fmt.Sprintf("custom/%s/%s/%s", types.QuerierRoute, keeper.QueryContractAddress, args[0])
res, _, err := clientCtx.Query(route)
if err != nil {
if err == sdkErrors.ErrUnknownAddress {
// In a case when the label will not be found err will be of type ErrUnknownAddress.
// But will include a lot of prior wrapping information for example:
// Error: error querying: rpc error: code = Unknown desc = l: unknown address
// In order to identify the error correctly we need to find the desc of ErrUnknownAddress in err
if strings.Contains(err.Error(), sdkErrors.ErrUnknownAddress.Error()) {
fmt.Printf("Label is available and not in use\n")
return nil
}
Expand Down

0 comments on commit 382ceac

Please sign in to comment.