cerr

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package cerr holds the semantic error classification shared by the gorefactor CLI and its importable refactoring engines. It carries a stable exit code and optional "did you mean" candidate list so that agents can key retries off the exit code and callers can render candidates uniformly.

Index

Constants

View Source
const (
	ExitOK          = 0 // success
	ExitUsage       = 1 // usage / argument error
	ExitNotFound    = 2 // target or pattern not found (semantic miss)
	ExitParseError  = 3 // snippet or file does not parse
	ExitGateFailure = 4 // build/test gate failed (doctor, --gate)
)

Semantic exit codes. Documented in the CLI usage; agents key retries off them.

Variables

This section is empty.

Functions

func Candidates

func Candidates(err error) []string

Candidates extracts the candidate list from a CLIError, if any.

func ClosestMatch

func ClosestMatch(name string, candidates []string) string

ClosestMatch returns the candidate with the smallest Levenshtein distance to name, when that distance is small enough to be a plausible typo.

func ExitCodeFor

func ExitCodeFor(err error) int

ExitCodeFor maps an error to its semantic exit code (default: usage error).

func Gatef

func Gatef(format string, a ...interface{}) error

Gatef builds an exit-4 gate-failure error.

func NotFound

func NotFound(summary, name string, candidates []string) error

NotFound builds an exit-2 error whose message lists the available candidates and, when one is close to name, a "did you mean" hint.

func NotFoundf

func NotFoundf(format string, a ...interface{}) error

NotFoundf builds an exit-2 not-found error.

func Parsef

func Parsef(format string, a ...interface{}) error

Parsef builds an exit-3 parse error.

func Usagef

func Usagef(format string, a ...interface{}) error

Usagef builds an exit-1 usage error.

Types

type CLIError

type CLIError struct {
	Code  int
	Msg   string
	Cands []string
}

CLIError carries a semantic exit code and optional candidate symbols for "did you mean" style guidance and --json error payloads. Its fields are exported so the CLI can both construct composite errors (e.g. txn wrapping) and inspect the code/message when deciding on fallbacks.

func (*CLIError) Error

func (e *CLIError) Error() string

Jump to

Keyboard shortcuts

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