From 75a60cf5191ec3728e3601e901ba2336e9fab85b Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Mon, 11 Sep 2017 19:37:58 +0000 Subject: [PATCH] Only print error message on kpod error not stacktrace If the user specifies --debug flag then print stack trace. Signed-off-by: Daniel J Walsh --- cmd/kpod/main.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cmd/kpod/main.go b/cmd/kpod/main.go index d5be45e9..c757f04f 100644 --- a/cmd/kpod/main.go +++ b/cmd/kpod/main.go @@ -1,6 +1,7 @@ package main import ( + "fmt" "os" "github.com/containers/storage/pkg/reexec" @@ -13,6 +14,8 @@ import ( var kpodVersion = "" func main() { + debug := false + if reexec.Init() { return } @@ -52,6 +55,7 @@ func main() { app.Before = func(c *cli.Context) error { logrus.SetLevel(logrus.ErrorLevel) if c.GlobalBool("debug") { + debug = true logrus.SetLevel(logrus.DebugLevel) } return nil @@ -97,7 +101,11 @@ func main() { }, } if err := app.Run(os.Args); err != nil { - logrus.Errorf(err.Error()) + if debug { + logrus.Errorf(err.Error()) + } else { + fmt.Println(err.Error()) + } cli.OsExiter(1) } }