codes

package
v0.44.1 Latest Latest
Warning

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

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

Documentation

Overview

Package codes is the closed registry of stable, machine-readable problem codes. Every typed error and every domain outcome that crosses a boundary carries one, so a single identifier joins the Go value, the structured log, the HTTP/JSON body, the CLI message, and the docs. Codes are namespaced by subsystem (NAMESPACE-### ); the string is a stable contract — never reword an existing code, add a new one.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Errorf

func Errorf(c Code, format string, a ...any) error

Errorf builds a coded *Error with a formatted message.

Types

type Code

type Code string

Code is one distinct problem condition.

const (
	GateNotClassified Code = "GATE-001" // PR never finalized a plan; apply fails closed
	GateNotSatisfied  Code = "GATE-002" // a required grant is not yet ACTIVE
	GateUnconfirmable Code = "GATE-003" // gate state could not be freshly confirmed (backend unreachable)
	GateUnreachable   Code = "GATE-004" // the approval server itself is unreachable (transport failure)
)

Gate-check outcomes (apply-time, fail-closed pre-check).

const (
	Internal Code = "SRV-001" // unexpected server-side error
)

Server-internal.

const (
	UnknownStatus Code = "WIRE-001" // a decoded payload carried a status outside the known set
)

Wire / protocol decode.

func All

func All() []Code

All returns every registered code (for the uniqueness/format test and the generated docs table). Retained as public API: the test suite validates uniqueness/format via this, and the generated docs reference table enumerates it.

type Coded

type Coded interface {
	Code() Code
}

Coded is implemented by errors and outcome values that carry a Code.

type Error

type Error struct {
	C   Code
	Msg string
}

Error is a coded operational error: it pairs a stable Code with a message so callers can branch on errors.As(err, *codes.Error) / Code() instead of matching message text.

func (*Error) Code

func (e *Error) Code() Code

Code implements Coded.

func (*Error) Error

func (e *Error) Error() string

Jump to

Keyboard shortcuts

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