clierr

package
v2.1.2 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2026 License: MIT Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package clierr defines the error contract the CLI presents to callers: a short machine code, an exit status, a message, and a hint.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExitCode

func ExitCode(code Code) int

ExitCode maps a code to the process exit status documented in `mail-app-cli help exit-codes`.

func Table

func Table() []struct {
	Code    Code
	Exit    int
	Meaning string
}

Table lists every code with its exit status and meaning, in exit order.

Types

type Code

type Code string

Code is the machine-readable category of a failure.

const (
	CodeUsage          Code = "usage"
	CodeNotFound       Code = "not_found"
	CodeUnavailable    Code = "unavailable"
	CodeTimeout        Code = "timeout"
	CodePartial        Code = "partial"
	CodeMutationFailed Code = "mutation_failed"
	CodeInternal       Code = "internal"
)

type Error

type Error struct {
	Code    Code
	Message string
	Hint    string
	Cause   error
	// Reported is set once the error has been written inside a result
	// envelope, so the process exits with its code without printing again.
	Reported bool
}

Error is the CLI-facing failure. Cause keeps the original error for %w.

func Classify

func Classify(err error) *Error

Classify converts any error into an *Error. Typed errors from pkg/mail map by type; the automation bridge's string errors map by content.

func New

func New(code Code, message string) *Error

New builds an error with a code and message.

func Usage

func Usage(message string) *Error

Usage builds a usage error.

func Usagef

func Usagef(format string, args ...any) *Error

Usagef builds a formatted usage error.

func Wrap

func Wrap(code Code, err error, message string) *Error

Wrap attaches a code and message to an underlying error.

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

func (*Error) WithHint

func (e *Error) WithHint(hint string) *Error

WithHint returns a copy carrying a remediation hint.

Jump to

Keyboard shortcuts

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