Documentation
¶
Overview ¶
Package errors defines a typed error taxonomy for Helix's MCP tools.
Import convention: use alias "serr" to avoid shadowing stdlib errors.
import serr "github.com/agenthands/helix/internal/errors"
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotFound = &Error{Kind: NotFound} ErrInvalidArgs = &Error{Kind: InvalidArgs} ErrNoWorkspace = &Error{Kind: NoWorkspace} ErrUnsupported = &Error{Kind: Unsupported} ErrInternal = &Error{Kind: Internal} ErrCircuitOpen = &Error{Kind: CircuitOpen} ErrTimeout = &Error{Kind: Timeout} )
Sentinel errors for use with errors.Is. Each sentinel carries only a Kind; Error.Is() compares Kind values, so errors.Is(err, ErrNotFound) matches any *Error with Kind == NotFound.
Functions ¶
This section is empty.
Types ¶
type Error ¶
type Error struct {
Kind Kind `json:"kind"`
Message string `json:"message"`
Tool string `json:"tool,omitempty"`
Detail string `json:"detail,omitempty"`
// contains filtered or unexported fields
}
Error is the structured error type for all Helix MCP tools. It carries a Kind for programmatic matching, a human-readable Message, an optional Tool name, an optional Detail string, and an unexported cause for error chain traversal.
CRITICAL: Functions returning the error interface must never assign a *Error nil pointer to a variable and return it. Always return nil directly. A typed nil *Error satisfies error as non-nil, causing false positives.
func Wrap ¶
Wrap creates a typed error that wraps a cause error, preserving the error chain for errors.Is and errors.As traversal.
func (*Error) Error ¶
Error returns a human-readable string: "kind: message" or "kind: message (detail)" when Detail is non-empty.
func (*Error) Is ¶
Is enables errors.Is matching by Kind. When the target is an *Error, it matches if both errors share the same Kind value. This allows sentinel-based matching: errors.Is(err, serr.ErrNotFound).
func (*Error) MarshalJSON ¶
MarshalJSON returns the JSON encoding of the Error. Uses a type alias to prevent infinite recursion through the json.Marshaler interface.
func (*Error) WithDetail ¶
WithDetail sets the detail string on the error and returns the same *Error for builder-style chaining.