etcdctl: print out better error information

This commit is contained in:
Xiang Li 2015-08-12 10:09:56 -07:00
parent 5d06d4ec44
commit 7e04a79fb4
2 changed files with 6 additions and 1 deletions

View File

@ -17,6 +17,8 @@ package command
import (
"fmt"
"os"
"github.com/coreos/etcd/client"
)
const (
@ -29,5 +31,8 @@ const (
func handleError(code int, err error) {
fmt.Fprintln(os.Stderr, "Error: ", err)
if cerr, ok := err.(*client.ClusterError); ok {
fmt.Fprintln(os.Stderr, cerr.Detail())
}
os.Exit(code)
}

View File

@ -215,7 +215,7 @@ func mustNewClient(c *cli.Context) client.Client {
err := hc.Sync(ctx)
cancel()
if err != nil {
fmt.Fprintln(os.Stderr, err.Error())
handleError(ExitServerError, err)
os.Exit(1)
}
}