AUTH-2686: Added error handling to tunnel subcommand

This commit is contained in:
Michael Borkenstein
2020-05-18 13:24:17 -05:00
parent df3ad2b223
commit 6a7418e1af
3 changed files with 30 additions and 25 deletions

View File

@@ -0,0 +1,17 @@
package cliutil
import "gopkg.in/urfave/cli.v2"
// Ensures exit with error code if actionFunc returns an error
func ErrorHandler(actionFunc cli.ActionFunc) cli.ActionFunc {
return func(ctx *cli.Context) error {
err := actionFunc(ctx)
if err != nil {
// os.Exits with error code if err is cli.ExitCoder or cli.MultiError
cli.HandleExitCoder(err)
err = cli.Exit(err.Error(), 1)
}
return err
}
}