From 700a55097356c53fa0f3eead25321e5331a538a3 Mon Sep 17 00:00:00 2001 From: Ekaterina Pavlova Date: Wed, 3 Apr 2024 19:17:44 +0300 Subject: [PATCH] cli: improve wallet unmarshalling error Made errors more user-friendly. ``` ./bin/neo-go wallet import --wif qweqweqweqwe -w wallet1.json failed to read wallet: open wallet: open wallet.json: no such file or directory touch wallet.json ./bin/neo-go wallet import --wif qweqweqweqwe -w wallet.json failed to read wallet: unmarshal wallet: EOF ``` Close #3134 Signed-off-by: Ekaterina Pavlova --- cli/wallet/wallet.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cli/wallet/wallet.go b/cli/wallet/wallet.go index e3b51d114..b3793e2a0 100644 --- a/cli/wallet/wallet.go +++ b/cli/wallet/wallet.go @@ -948,14 +948,14 @@ func createAccount(wall *wallet.Wallet, pass *string) error { func openWallet(ctx *cli.Context, canUseWalletConfig bool) (*wallet.Wallet, *string, error) { path, pass, err := getWalletPathAndPass(ctx, canUseWalletConfig) if err != nil { - return nil, nil, err + return nil, nil, cli.NewExitError(fmt.Errorf("failed to get wallet path or password: %w", err), 1) } if path == "-" { return nil, nil, errNoStdin } w, err := wallet.NewWalletFromFile(path) if err != nil { - return nil, nil, err + return nil, nil, cli.NewExitError(fmt.Errorf("failed to read wallet: %w", err), 1) } return w, pass, nil }