From 86cde9fc83f29bc8a4944c0cbacff8f59f7ab8a1 Mon Sep 17 00:00:00 2001 From: Sam Date: Sat, 10 Aug 2019 10:36:06 -0400 Subject: [PATCH] Add better error handling to wallet api --- wallet.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/wallet.go b/wallet.go index 6618e18..357bf23 100644 --- a/wallet.go +++ b/wallet.go @@ -2,6 +2,7 @@ package keybase import ( "encoding/json" + "errors" "os/exec" ) @@ -17,7 +18,9 @@ func walletAPIOut(keybasePath string, w WalletAPI) (WalletAPI, error) { var r WalletAPI json.Unmarshal(cmdOut, &r) - + if r.Error != nil { + return WalletAPI{}, errors.New(r.Error.Message) + } return r, nil } @@ -42,5 +45,8 @@ func (k *Keybase) StellarAddress(user string) (string, error) { m.Params.Options.Name = user r, err := walletAPIOut(k.Path, m) + if err != nil { + return "", err + } return r.Result.AccountID, err }