exitcode

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: Apache-2.0 Imports: 2 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 exitcode holds the CLI's stable exit codes (CLT-15/FR-17) and the typed error that carries one, so every layer can say what went wrong without knowing how the process exits.

Index

Constants

View Source
const (
	OK          = 0
	General     = 1
	Usage       = 2
	Auth        = 3
	NotFound    = 4
	Conflict    = 5
	Billing     = 6
	Unavailable = 7
	Timeout     = 8
	Partial     = 9
	RunFailed   = 10
	Interrupted = 130
)

Stable exit codes. They are part of the CLI's public contract: scripts and agents branch on them.

Variables

This section is empty.

Functions

func Of

func Of(err error) int

Of returns the exit code for any error: the typed code, or General for anything else.

Types

type Error

type Error struct {
	Code      int    // exit code
	APICode   string // the API's error code (or a CLI code such as "confirmation_required")
	Message   string
	Hint      string
	Status    int // HTTP status, 0 when none
	RequestID string
	Cause     error
}

Error is an expected failure: what failed, a stable machine code, a hint for what to do next, and the exit code the process ends with.

func As

func As(err error) *Error

As extracts the typed error, wrapping a plain error as General.

func New

func New(code int, apiCode, message string) *Error

New builds an Error with an exit code and a message.

func Usagef

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

Usagef is a usage error (exit 2): bad flags or arguments.

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 the error with a hint attached.

Jump to

Keyboard shortcuts

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