From 3b4b03615ad308a7ef462e67e1f2199379c19bbb Mon Sep 17 00:00:00 2001 From: Lior Bondarevski Date: Sun, 21 Aug 2022 17:11:37 +0300 Subject: [PATCH] Correct the error in label cli --- x/compute/client/cli/query.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/x/compute/client/cli/query.go b/x/compute/client/cli/query.go index bc26f67ad..11a875476 100644 --- a/x/compute/client/cli/query.go +++ b/x/compute/client/cli/query.go @@ -9,6 +9,7 @@ import ( "fmt" "io/ioutil" "strconv" + "strings" "github.com/gogo/protobuf/proto" @@ -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 }