exitcode

package
v0.35.0 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package exitcode is the error type that the publisher commands return for a failure that is not a finding: bad usage, or an environment that cannot run the command. It carries exit code 2.

The process exit code is chosen by main's commandExitCode, which passes through the ExitCode() of any error in the chain (errors.As) when it is in 1..255 and otherwise exits 1. So returning one of these errors from a command is all that is needed, and no existing command changes: they return plain errors and keep exiting 1.

By the convention of the publisher commands, 0 means everything passed, 1 means the check ran and found something wrong, and 2 means it could not run as asked.

Index

Constants

View Source
const UsageCode = 2

UsageCode is the exit code for a usage or environment error.

Variables

This section is empty.

Functions

func Usage

func Usage(err error) error

Usage wraps err as a usage or environment error: exit code 2. It returns nil for a nil error.

func Usagef

func Usagef(format string, args ...any) error

Usagef is Usage of fmt.Errorf(format, args...); a %w verb wraps as usual.

Types

type Error

type Error struct {
	// contains filtered or unexported fields
}

Error is an error that carries an exit code.

func (*Error) Error

func (e *Error) Error() string

Error returns the message of the wrapped error.

func (*Error) ExitCode

func (e *Error) ExitCode() int

ExitCode returns the process exit code for the error.

func (*Error) Unwrap

func (e *Error) Unwrap() error

Unwrap returns the wrapped error, so errors.Is and errors.As see through it.

Jump to

Keyboard shortcuts

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