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 <dwalsh@redhat.com>
This commit is contained in:
parent
c56dcf2cb5
commit
75a60cf519
1 changed files with 9 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/containers/storage/pkg/reexec"
|
"github.com/containers/storage/pkg/reexec"
|
||||||
|
@ -13,6 +14,8 @@ import (
|
||||||
var kpodVersion = ""
|
var kpodVersion = ""
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
debug := false
|
||||||
|
|
||||||
if reexec.Init() {
|
if reexec.Init() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -52,6 +55,7 @@ func main() {
|
||||||
app.Before = func(c *cli.Context) error {
|
app.Before = func(c *cli.Context) error {
|
||||||
logrus.SetLevel(logrus.ErrorLevel)
|
logrus.SetLevel(logrus.ErrorLevel)
|
||||||
if c.GlobalBool("debug") {
|
if c.GlobalBool("debug") {
|
||||||
|
debug = true
|
||||||
logrus.SetLevel(logrus.DebugLevel)
|
logrus.SetLevel(logrus.DebugLevel)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -97,7 +101,11 @@ func main() {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
if err := app.Run(os.Args); err != nil {
|
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)
|
cli.OsExiter(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue