errclass

package
v0.24.0 Latest Latest
Warning

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

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

Documentation

Overview

Package errclass classifies the raw output of a failed build, test, or run command into a small, closed set of categories and pairs it with a short explanation template. It is the build/runtime sibling of the provider/model error classification: where that path decides retry behavior from typed errors, this one reads command output, which is untyped text, and answers "what kind of failure is this?" without calling a model.

Classification is deterministic pattern matching over the raw output. It is deliberately conservative: output that matches no known shape is reported as CategoryUnknown rather than guessed at. A result always carries the raw output verbatim alongside the explanation, which accompanies the output and never replaces it — a reader (or the model that will attempt a fix) sees both.

The package is pure stdlib and holds no state, so a caller can classify a captured excerpt (verify.Check.Excerpt, or a run's own output) and consume the category and explanation directly. Deterministic patterns keep the result stable across runs for the same input.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Category

type Category string

Category is the kind of build or runtime failure. The set is closed: every classification lands in exactly one of these, and CategoryUnknown is the honest answer when nothing matches.

const (
	// CategoryMissingDependency is a build that cannot resolve a package,
	// module, or import: the code references something that is not
	// installed or declared.
	CategoryMissingDependency Category = "missing-dependency"
	// CategorySyntaxError is source that cannot be parsed: a malformed
	// token, an unexpected end of input, an unclosed construct.
	CategorySyntaxError Category = "syntax-error"
	// CategoryTypeError is source that parses but does not type-check: a
	// value of the wrong type, an undefined name, a bad conversion.
	CategoryTypeError Category = "type-error"
	// CategoryFailingTest is a test suite that ran and reported a failure
	// rather than a build error.
	CategoryFailingTest Category = "failing-test"
	// CategoryAppCrash is a process that crashed on start or stopped
	// unexpectedly at runtime: a panic, a fatal error, a port or resource
	// already in use.
	CategoryAppCrash Category = "app-crash"
	// CategoryUnknown is the answer when the output matches no known
	// failure shape. It is never a guess.
	CategoryUnknown Category = "unknown"
)

func Categories

func Categories() []Category

Categories returns the closed set of categories in a stable order, for callers that iterate or display the taxonomy.

func (Category) Explanation

func (c Category) Explanation() string

Explanation returns the fixed short explanation template for the category. It never includes the raw output; callers present it next to the output.

func (Category) Known

func (c Category) Known() bool

Known reports whether the category is one of the classified failures (any category other than CategoryUnknown).

type Result

type Result struct {
	// Category is the classified failure kind (CategoryUnknown when
	// nothing matched).
	Category Category
	// Explanation is the short template for the category.
	Explanation string
	// Raw is the input output, preserved verbatim.
	Raw string
	// Signal is the concrete pattern that decided the category, when one
	// did, e.g. "cannot find package". It is empty for CategoryUnknown.
	// It is diagnostic only: a caller may log it, it is not part of the
	// display contract.
	Signal string
}

Result is a classification plus the evidence it was derived from. Raw always holds the input output verbatim, so the explanation accompanies it rather than replacing it.

func Classify

func Classify(output string) Result

Classify inspects raw command output from a failed build, test, or run and returns its category and the explanation template. It never modifies the input: Result.Raw is the exact string passed in.

Jump to

Keyboard shortcuts

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