exitcode

package
v3.0.0-alpha.2 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: BSD-2-Clause Imports: 8 Imported by: 0

Documentation

Overview

Package exitcode turns the error a tt command ends with into the process exit status, and reports that error to the user once.

The codes and the carrier that sets them are the SDK's (sdk.ExitError, sdk.ExitCode). This package adds the policy that belongs to tt rather than to the contract: which uncoded failures are the system's (Code), which errors the user has already seen (Silent), and the one place that logs an error and ends the process for code that cannot return it (Exit).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Code

func Code(err error) int

Code returns the process exit code tt ends with for err, whichever command returned it: sdk.ExitOK for nil; a code other than sdk.ExitFailure that err carries; sdk.ExitSystem when err is a failure of the system (see systemFailure); sdk.ExitFailure otherwise.

sdk.ExitFailure is the code every command wraps its errors in, so it is the weakest: a server that cannot be reached, wrapped as "resolving dependencies" with code 1, is still a system failure. A code other than 1 is a deliberate verdict - a build backend that failed, a multi-package install that partly succeeded, an external module's own status - and stands.

func Exit

func Exit(err error)

Exit reports err and ends the process with Code(err); a nil err exits sdk.ExitOK.

A command returns its error to the root, which reports it and exits there. Exit is for the code that cannot: a callback of an interactive prompt that has no caller to return to.

func IsSilent

func IsSilent(err error) bool

IsSilent reports whether err, or an error it wraps, was marked by Silent.

func Report

func Report(err error)

Report logs err as one error record, unless it is nil or silent.

func Silent

func Silent(err error) error

Silent marks err as already reported, so Report does not log it: an external module that printed its own failure, a prompt the user declined. Its exit code is still err's. Silent(nil) is nil.

Types

This section is empty.

Jump to

Keyboard shortcuts

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