exitcode

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: MIT 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 defines the CLI's stable process exit codes and a typed error that carries the intended code, so the mapping lives in exactly one place (unwrapped once in cmd/vibexp/main.go).

Index

Constants

View Source
const (
	OK         = 0 // success
	RuntimeErr = 1 // API or runtime error
	UsageErr   = 2 // invalid usage (bad flags/args)
	AuthErr    = 4 // authentication/authorization failure
)

Stable exit codes. These are part of the CLI's scripting contract — do not renumber. Documented in docs/architecture.md.

Variables

This section is empty.

Functions

func FromError

func FromError(err error) int

FromError resolves the process exit code for err:

  • nil -> OK (0)
  • wraps a CodedError -> that code
  • anything else -> RuntimeErr (1)

Types

type CodedError

type CodedError struct {
	Code int
	Err  error
}

CodedError wraps an error with the process exit code it should produce.

func Auth

func Auth(format string, args ...any) *CodedError

Auth is a convenience constructor for auth (exit 4) errors.

func New

func New(code int, err error) *CodedError

New wraps err with the given exit code.

func Newf

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

Newf wraps a formatted message with the given exit code.

func Usage

func Usage(format string, args ...any) *CodedError

Usage is a convenience constructor for usage (exit 2) errors.

func (*CodedError) Error

func (e *CodedError) Error() string

func (*CodedError) ExitCode

func (e *CodedError) ExitCode() int

ExitCode reports the process exit code, satisfying ExitCoder.

func (*CodedError) Unwrap

func (e *CodedError) Unwrap() error

Unwrap exposes the wrapped error to errors.Is / errors.As.

type ExitCoder

type ExitCoder interface {
	ExitCode() int
}

ExitCoder is any error that knows its intended process exit code. Both *CodedError and the API error layer implement it.

Jump to

Keyboard shortcuts

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