mirror of
https://github.com/cloudflare/cloudflared.git
synced 2025-07-28 11:59:58 +00:00
AUTH-2686: Added error handling to tunnel subcommand
This commit is contained in:
17
cmd/cloudflared/cliutil/errors.go
Normal file
17
cmd/cloudflared/cliutil/errors.go
Normal 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
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user