gaiacli, keys: Improve error message when deleting non-existant key
This commit is contained in:
parent
6ea47f40ef
commit
0b10430d65
|
@ -80,8 +80,9 @@ IMPROVEMENTS
|
|||
* [stake] module reorganized to include `types` and `keeper` package
|
||||
* [stake] keeper always loads the store (instead passing around which doesn't really boost efficiency)
|
||||
* [stake] edit-validator changes now can use the keyword [do-not-modify] to not modify unspecified `--flag` (aka won't set them to `""` value)
|
||||
* [types] added common tag constants
|
||||
* [stake] offload more generic functionality from the handler into the keeper
|
||||
* [types] added common tag constants
|
||||
* [keys] improve error message when deleting non-existent key
|
||||
* added contributing guidelines
|
||||
|
||||
BUG FIXES
|
||||
|
|
|
@ -25,14 +25,19 @@ func deleteKeyCommand() *cobra.Command {
|
|||
func runDeleteCmd(cmd *cobra.Command, args []string) error {
|
||||
name := args[0]
|
||||
|
||||
buf := client.BufferStdin()
|
||||
oldpass, err := client.GetPassword(
|
||||
"DANGER - enter password to permanently delete key:", buf)
|
||||
kb, err := GetKeyBase()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
kb, err := GetKeyBase()
|
||||
_, err = kb.Get(name)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
buf := client.BufferStdin()
|
||||
oldpass, err := client.GetPassword(
|
||||
"DANGER - enter password to permanently delete key:", buf)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -188,6 +188,9 @@ func (kb dbKeybase) List() ([]Info, error) {
|
|||
// Get returns the public information about one key.
|
||||
func (kb dbKeybase) Get(name string) (Info, error) {
|
||||
bs := kb.db.Get(infoKey(name))
|
||||
if len(bs) == 0 {
|
||||
return nil, fmt.Errorf("Key %s not found", name)
|
||||
}
|
||||
return readInfo(bs)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue