errcode

package
v0.0.0-...-c671013 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: Apache-2.0 Imports: 0 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package errcode defines the structured error taxonomy surfaced to agents.

Every error returned to an agent carries a stable Code plus an optional Hint that names the tool the agent should call next and the arguments it should pass. Agents recover without reading prose.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Code

type Code string

Code is a stable identifier for an error class. Agents branch on Code; humans read the accompanying message. Values are dotted, lower-kebab per segment, and MUST NOT be renamed once released.

const (
	// Input / configuration errors.
	TargetMissing        Code = "target.missing"
	TargetInvalid        Code = "target.invalid"
	TargetUnreachable    Code = "target.unreachable"
	TargetConnectFailed  Code = "target.connect-failed"
	ServiceMissing       Code = "input.service-missing"
	MethodMissing        Code = "input.method-missing"
	ArgsInvalid          Code = "input.args-invalid"
	ProfileNotDefined    Code = "input.profile-not-defined"
	MethodAmbiguous      Code = "contract.method-ambiguous"
	MethodNotFound       Code = "contract.method-not-found"
	ContractUnresolvable Code = "contract.unresolvable"

	// Workspace / project errors.
	FacadeNotConfigured Code = "workspace.facade-not-configured"

	// Replay / captured plan errors.
	PlanVersionUnsupported Code = "replay.plan-version-unsupported"

	// Runtime / invoke errors.
	SerializeFailed    Code = "runtime.serialize-failed"
	DeserializeFailed  Code = "runtime.deserialize-failed"
	InvocationTimeout  Code = "runtime.timeout"
	InvocationCanceled Code = "runtime.canceled"
	ProtocolFailed     Code = "runtime.protocol-failed"
	InvocationRejected Code = "runtime.rejected"
	InvocationBusy     Code = "runtime.busy"
	InternalFailure    Code = "runtime.internal"
)

type Error

type Error struct {
	Code    Code   `json:"code"`
	Message string `json:"message"`
	Phase   string `json:"phase,omitempty"`
	Hint    *Hint  `json:"hint,omitempty"`
}

Error is the canonical structured error. Code + Message are always set; Phase groups errors by pipeline stage (resolve / contract / invoke); Hint carries the agent-facing recovery suggestion.

func New

func New(code Code, phase, message string) *Error

New builds an Error without a hint.

func (*Error) Error

func (e *Error) Error() string

func (*Error) WithHint

func (e *Error) WithHint(nextTool string, nextArgs map[string]any, reason string) *Error

WithHint attaches a hint and returns the same error for chaining.

type Hint

type Hint struct {
	NextTool string         `json:"nextTool,omitempty"`
	NextArgs map[string]any `json:"nextArgs,omitempty"`
	Reason   string         `json:"reason,omitempty"`
}

Hint points the agent at its next action. NextTool names a tool the agent can already see; NextArgs is the argument object to pass into it. Both are optional — a hint may carry only NextArgs to pre-fill a form, or only NextTool to suggest a diagnostic.

Jump to

Keyboard shortcuts

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