MCPcopy Index your code
hub / github.com/cloudflare/cloudflared / WithErrorHandler

Function WithErrorHandler

cmd/cloudflared/cliutil/errors.go:25–38  ·  view source on GitHub ↗

Ensures exit with error code if actionFunc returns an error

(actionFunc cli.ActionFunc)

Source from the content-addressed store, hash-verified

23
24// Ensures exit with error code if actionFunc returns an error
25func WithErrorHandler(actionFunc cli.ActionFunc) cli.ActionFunc {
26 return func(ctx *cli.Context) error {
27 err := actionFunc(ctx)
28 if err != nil {
29 if _, ok := err.(usageError); ok {
30 msg := fmt.Sprintf("%s\nSee 'cloudflared %s --help'.", err.Error(), ctx.Command.FullName())
31 err = cli.Exit(msg, -1)
32 } else if _, ok := err.(cli.ExitCoder); !ok {
33 err = cli.Exit(err.Error(), 1)
34 }
35 }
36 return err
37 }
38}

Callers 2

ActionFunction · 0.85

Calls 1

ErrorMethod · 0.45

Tested by

no test coverage detected