Browse Source

Add better error handling to wallet api

main
Sam 6 years ago
parent
commit
86cde9fc83
  1. 8
      wallet.go

8
wallet.go

@ -2,6 +2,7 @@ package keybase
import ( import (
"encoding/json" "encoding/json"
"errors"
"os/exec" "os/exec"
) )
@ -17,7 +18,9 @@ func walletAPIOut(keybasePath string, w WalletAPI) (WalletAPI, error) {
var r WalletAPI var r WalletAPI
json.Unmarshal(cmdOut, &r) json.Unmarshal(cmdOut, &r)
if r.Error != nil {
return WalletAPI{}, errors.New(r.Error.Message)
}
return r, nil return r, nil
} }
@ -42,5 +45,8 @@ func (k *Keybase) StellarAddress(user string) (string, error) {
m.Params.Options.Name = user m.Params.Options.Name = user
r, err := walletAPIOut(k.Path, m) r, err := walletAPIOut(k.Path, m)
if err != nil {
return "", err
}
return r.Result.AccountID, err return r.Result.AccountID, err
} }

Loading…
Cancel
Save