catalog

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package catalog is the offline, embedded error-code knowledge base that powers `normatik explain` and the exit-code policy. It is generated from the backend sources (ErrorCode.java + PublicApiHints.java) by api/gen-catalog.mjs and embedded at build time, so the CLI explains every documented error without a network round-trip. `make verify` fails if the JSON drifts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Closest

func Closest(code string) string

Closest returns the catalogued name with the smallest edit distance (<=3), for "did you mean?" suggestions on an unknown code. Empty if nothing is close.

func ExitFor

func ExitFor(code string, status int) int

ExitFor is the single source of truth for mapping an (errorCode, httpStatus) pair to a stable exit code. Both Problem.ExitCode and any future caller route through here. For a known code with no wire status we fall back to the catalogued status (defends against a proxy rewriting the HTTP status).

func Names

func Names() []string

Names returns every error-code name, sorted — used for shell completion.

Types

type Entry

type Entry struct {
	Name        string `json:"name"`
	Status      int    `json:"status"`
	Title       string `json:"title"`
	UserMessage string `json:"userMessage"`
	HintKind    string `json:"hintKind"`
	ExitCode    int    `json:"exitCode"`
	StaticHint  string `json:"staticHint,omitempty"`
}

Entry is one documented ErrorCode. HintKind is STATIC|DYNAMIC|NO_HINT — matching the backend's three-set discipline (PublicApiHints).

func List

func List() []Entry

List returns all entries, sorted by name (the generator sorts them).

func Lookup

func Lookup(code string) (Entry, bool)

Lookup finds an entry by code (case-insensitive).

type ExitClass

type ExitClass struct {
	Code    int
	Meaning string
}

ExitClass is one row of the exit-code policy table.

func ExitClasses

func ExitClasses() []ExitClass

ExitClasses is the documented exit-code table (`explain exit-codes`). It is the single human-readable companion to ExitFor.

Jump to

Keyboard shortcuts

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