exitcode

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Success          = 0
	General          = 1
	Usage            = 2
	Authentication   = 3
	NotFound         = 4
	PermissionDenied = 5
	RateLimited      = 6
)

Exit codes matching README documentation.

Variables

This section is empty.

Functions

func CodeFrom

func CodeFrom(err error) int

CodeFrom extracts the exit code from an error. If the error contains an *Error anywhere in its chain, that code is returned. Otherwise returns General (1).

func CodeName

func CodeName(code int) string

CodeName returns a short string label for an exit code.

Types

type Error

type Error struct {
	Code    int
	Message string
	Err     error // optional wrapped error
}

Error is an error that carries a specific exit code.

func New

func New(code int, msg string) *Error

New returns a new Error with the given code and message.

func Wrap

func Wrap(code int, err error) *Error

Wrap returns a new Error with the given code wrapping err.

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

Jump to

Keyboard shortcuts

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