From 59baecd39b3f5871ce3f8cbfae6f93970ae92484 Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Mon, 20 Nov 2023 20:12:28 +0300 Subject: [PATCH] wallet: provide more detailed errors on failed NewWalletFromFile Close #3180. Signed-off-by: Anna Shaleva --- pkg/wallet/wallet.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/wallet/wallet.go b/pkg/wallet/wallet.go index a5fa85f96..ade1d3146 100644 --- a/pkg/wallet/wallet.go +++ b/pkg/wallet/wallet.go @@ -3,6 +3,7 @@ package wallet import ( "encoding/json" "errors" + "fmt" "io" "os" @@ -56,7 +57,7 @@ func NewWallet(location string) (*Wallet, error) { func NewWalletFromFile(path string) (*Wallet, error) { file, err := os.Open(path) if err != nil { - return nil, err + return nil, fmt.Errorf("open wallet: %w", err) } defer file.Close() @@ -64,7 +65,7 @@ func NewWalletFromFile(path string) (*Wallet, error) { path: file.Name(), } if err := json.NewDecoder(file).Decode(wall); err != nil { - return nil, err + return nil, fmt.Errorf("unmarshal wallet: %w", err) } return wall, nil }