From d06c589436ba44b7448487146fe5e7b38ff5c471 Mon Sep 17 00:00:00 2001 From: HaoyangLiu Date: Fri, 21 Sep 2018 23:44:39 +0800 Subject: [PATCH] Merge PR #2370: Improve error handler in certifier creation --- client/context/context.go | 6 ++++-- client/rpc/validators.go | 3 +-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/client/context/context.go b/client/context/context.go index db6fbef7d3..0497761c67 100644 --- a/client/context/context.go +++ b/client/context/context.go @@ -94,13 +94,15 @@ func createCertifier() tmlite.Certifier { errMsg.WriteString("--node ") } if errMsg.Len() != 0 { - fmt.Printf("must specify these options: %s when --trust-node is false\n", errMsg.String()) + fmt.Printf("Must specify these options: %s when --trust-node is false\n", errMsg.String()) os.Exit(1) } certifier, err := tmliteProxy.GetCertifier(chainID, home, nodeURI) if err != nil { - panic(err) + fmt.Printf("Create certifier failed: %s\n", err.Error()) + fmt.Printf("Please check network connection and verify the address of the node to connect to\n") + os.Exit(1) } return certifier diff --git a/client/rpc/validators.go b/client/rpc/validators.go index f708cb1456..0583dc0545 100644 --- a/client/rpc/validators.go +++ b/client/rpc/validators.go @@ -12,7 +12,6 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/context" sdk "github.com/cosmos/cosmos-sdk/types" - tmTypes "github.com/tendermint/tendermint/types" tmtypes "github.com/tendermint/tendermint/types" ) @@ -78,7 +77,7 @@ func getValidators(cliCtx context.CLIContext, height *int64) ([]byte, error) { return nil, err } - if !bytes.Equal(check.ValidatorsHash(), tmTypes.NewValidatorSet(validatorsRes.Validators).Hash()) { + if !bytes.Equal(check.ValidatorsHash(), tmtypes.NewValidatorSet(validatorsRes.Validators).Hash()) { return nil, fmt.Errorf("got invalid validatorset") } }