exitcode

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package exitcode defines the hadron CLI's stable, documented exit codes. These are part of the public contract (D8): agents and scripts branch on them, so values must never be repurposed.

Index

Constants

View Source
const (
	OK           = 0 // success
	Error        = 1 // generic failure
	Usage        = 2 // invalid usage: bad flags, bad input, not-yet-implemented
	AuthRequired = 3 // no credentials, or credentials rejected
	NotFound     = 4 // requested entity does not exist (or is not visible)
	Conflict     = 5 // state conflict, e.g. duplicate install
	Cancelled    = 6 // interrupted or timed out waiting for the user
)

Variables

View Source
var ErrSilent = errors.New("silent")

ErrSilent marks an error whose message has already been rendered by the command; the root handler sets the exit code but prints nothing further.

Functions

func FromError

func FromError(err error) int

FromError extracts the exit code from an error chain, defaulting to Error for any unrecognized failure.

Types

type CodedError

type CodedError struct {
	Code int
	Err  error
}

CodedError carries an exit code alongside an error. The root command unwraps it to decide the process exit code.

func New

func New(code int, err error) *CodedError

New wraps err with an exit code.

func Newf

func Newf(code int, format string, args ...any) *CodedError

Newf creates a CodedError from a format string.

func Silent

func Silent(code int) *CodedError

Silent returns a CodedError that only carries an exit code.

func (*CodedError) Error

func (e *CodedError) Error() string

func (*CodedError) Unwrap

func (e *CodedError) Unwrap() error

Jump to

Keyboard shortcuts

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