Documentation
¶
Index ¶
Constants ¶
const ( ExitOK = 0 // Success ExitGeneral = 1 // General application error ExitUsage = 2 // Usage/argument error (missing args, invalid flags) ExitNotFound = 3 // Resource not found (template, library) ExitInterrupted = 130 // Interrupted by SIGINT (Ctrl+C) )
Exit codes following POSIX conventions.
Variables ¶
This section is empty.
Functions ¶
func Errorf ¶
Errorf creates a new CommandError with a formatted message and exit code 1. It supports the %w verb for wrapping errors, similar to fmt.Errorf.
func NotFoundErrorf ¶
NotFoundErrorf creates a CommandError with exit code 3 (resource not found).
func UsageErrorf ¶
UsageErrorf creates a CommandError with exit code 2 (usage/argument error).
Types ¶
type CommandError ¶
CommandError represents an error that occurred during command execution. It wraps an underlying cause error and provides a user-friendly message. Implements cli.ExitCoder so urfave/cli can extract the exit code.
func (*CommandError) ExitCode ¶
func (e *CommandError) ExitCode() int
ExitCode returns the exit code for this error. If Code is explicitly set, it is returned. Otherwise defaults to ExitGeneral (1). Implements the cli.ExitCoder interface.
func (*CommandError) Unwrap ¶
func (e *CommandError) Unwrap() error
Unwrap returns the underlying cause error, enabling errors.Is and errors.As.