exitmap

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package exitmap provides centralized error-to-exit-code mapping for the CLI.

All CLI commands should use ToExit() to convert internal errors to exit codes. This ensures consistent exit codes across the codebase and prevents exit code logic from being scattered across multiple packages.

Security: All error messages are passed through redact.Error() before being returned to sanitize any sensitive information (tokens, secrets, etc.).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToExit

func ToExit(err error) (msg string, code int)

ToExit converts an error to an exit code and sanitized message. It extracts the exit code from errors.Error (which implements ExitCode()). Falls back to general error (exit code 1) for non-typed errors.

The returned message is always sanitized via redact.Error().

Types

type Result

type Result struct {
	Code    int
	Message string
}

Result holds the exit code and message from ToExit. This is a convenience type for commands that need to return both.

func ToExitResult

func ToExitResult(err error) Result

ToExitResult is like ToExit but returns a Result struct.

Jump to

Keyboard shortcuts

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