app

package
v0.38.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 8, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
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

func Errorf(format string, args ...any) error

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

func NotFoundErrorf(format string, args ...any) error

NotFoundErrorf creates a CommandError with exit code 3 (resource not found).

func UsageErrorf

func UsageErrorf(format string, args ...any) error

UsageErrorf creates a CommandError with exit code 2 (usage/argument error).

Types

type CommandError

type CommandError struct {
	Message string
	Cause   error
	Code    int
}

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) Error

func (e *CommandError) Error() string

Error returns the error message.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL