MCPcopy
hub / github.com/urfave/cli / Exit

Function Exit

errors.go:113–129  ·  errors.go::Exit

Exit wraps a message and exit code into an error, which by default is handled with a call to os.Exit during default error handling. This is the simplest way to trigger a non-zero exit code for a Command without having to call os.Exit manually. During testing, this behavior can be avoided by overrid

(message any, exitCode int)

Source from the content-addressed store, hash-verified

111// by overriding the ExitErrHandler function on a Command or the package-global
112// OsExiter function.
113func Exit(message any, exitCode int) ExitCoder {
114 var err error
115
116 switch e := message.(type) {
117 case ErrorFormatter:
118 err = fmt.Errorf("%+v", message)
119 case error:
120 err = e
121 default:
122 err = fmt.Errorf("%+v", message)
123 }
124
125 return &exitError{
126 err: err,
127 exitCode: exitCode,
128 }
129}
130
131func (ee *exitError) Error() string {
132 return ee.err.Error()

Calls

no outgoing calls