clierror

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidInput indicates invalid user input.
	ErrInvalidInput = errors.New("invalid input")

	// ErrAuthFailed indicates an authentication operation failed.
	ErrAuthFailed = errors.New("authentication failed")

	// ErrNotFound indicates a requested resource was not found.
	ErrNotFound = errors.New("not found")

	// ErrForbidden indicates access to a resource is forbidden.
	ErrForbidden = errors.New("forbidden")
)
View Source
var ErrCancelled = errors.New("cancelled")

ErrCancelled marks a deliberate user cancellation, such as choosing Cancel from a menu; it exits 0 silently.

Functions

func ExitCode

func ExitCode(err error) (int, bool)

ExitCode returns the requested silent exit status, if present in err's chain.

func HintOf

func HintOf(err error) string

HintOf returns the first attached hint in err's chain, or an empty string.

func IsUsage

func IsUsage(err error) bool

IsUsage reports whether err's chain contains an invocation error.

func MarkAs

func MarkAs(kind error, format string, a ...any) error

MarkAs formats an error and associates it with kind for errors.Is.

func Passthrough

func Passthrough(err error, what string) error

Passthrough converts a child process's non-zero exit into a bare exit-code error (the child already printed its own failure); other errors are wrapped with context. Signal-terminated processes have no usable exit status and are wrapped rather than converted.

func Prompt

func Prompt(err error, format string, a ...any) error

Prompt classifies a failed huh prompt. Ctrl-C at a prompt surfaces as huh.ErrUserAborted (the form runs in raw mode, so no SIGINT is delivered); it is treated like any other interrupt and exits 130. Anything else, such as no terminal being available, is a real failure and is reported with context rather than being mistaken for a cancellation.

func Usage

func Usage(err error) error

Usage marks err as an invocation error for which usage should be printed.

func WithExitCode

func WithExitCode(code int) error

WithExitCode requests a silent exit with code, for a child that reported its own failure.

func WithHint

func WithHint(err error, hint string) error

WithHint attaches a remediation hint to err.

Types

This section is empty.

Jump to

Keyboard shortcuts

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