DOCUMENTATION

Doc — Error Code Reference

DOCUMENTATION

doc - XCX Error Code Reference Manual

doc is the official offline error code reference tool for XCX. It looks up compiler and runtime error codes and prints a formatted explanation with a short example, directly in your terminal.

Overview

XCX raises errors using short alphanumeric codes (e.g. S103, R305, D401). The doc tool maps each code to a human-readable title, series, explanation, and example, without requiring an internet connection.

$ sh
_ ⛶ ×
1xcx doc S103
2xcx doc R305
3xcx doc list

No network access is required - the entire registry is bundled with the project.

Directory Structure

$ text
_ ⛶ ×
1doc/
2├── project.pax # Project configuration
3├── doc.xcx # Entry point - argument parsing & dispatch
4└── src/
5 ├── errors.xcx # Full error registry (code -> packed entry)
6 ├── lookup.xcx # Code lookup & parsing logic
7 └── format.xcx # Terminal output formatting

Installation

$ sh
_ ⛶ ×
1xcx pax clone doc
2cd doc
3xcx pax run
  • xcx pax clone doc downloads the published package as a local project.
  • No xcx pax install step is needed - doc declares zero dependencies.

Command Reference

doc is invoked via xcx doc <argument>.

CommandDescription
xcx doc <CODE>Look up a single error code and print its explanation.
xcx doc listPrint every registered code, grouped by series.
xcx docPrint usage help (no argument supplied).

Command Details

xcx doc <CODE>

Looks up a single error code (case-insensitive, whitespace-trimmed) and prints its title, series, explanation, and a short code example.

$ sh
_ ⛶ ×
1xcx doc S103
$ text
_ ⛶ ×
1 S103 Type mismatch
2 Series : Semantic
3
4 The type of the value or expression does not match what is expected.
5 Check that you are not assigning a string to an integer, or passing
6 the wrong type to a function.
7
8 Example
9 i: age = "twenty"; --- S103: expected i, got s

If the code does not exist in the registry, doc prints a not-found message instead of an explanation:

$ sh
_ ⛶ ×
1xcx doc Z999
$ text
_ ⛶ ×
1doc: unknown error code 'Z999'
2Run 'xcx doc list' to see all available codes.

xcx doc list

Prints every registered error code, sorted alphabetically and grouped under its series header (Semantic, Runtime, Database, etc.).

$ sh
_ ⛶ ×
1xcx doc list
$ text
_ ⛶ ×
1 XCX Error Codes
2
3 -- Database --
4 D401 Remove without where
5
6 -- Runtime --
7 R103 Input type mismatch
8 R303 Index out of bounds
9 R304 Column not found
10 R305 Invalid JSON
11 ...
12
13 -- Semantic --
14 S101 Undefined variable
15 S102 Redefined variable
16 S103 Type mismatch
17 ...

xcx doc (no arguments)

Prints short usage help when no code is supplied.

$ sh
_ ⛶ ×
1xcx doc
$ text
_ ⛶ ×
1doc - XCX Error Code Reference
2Usage: xcx doc <CODE>
3 xcx doc list
4
5Examples:
6 xcx doc S103
7 xcx doc R305
8 xcx doc list

Error Code Series

Codes are grouped into series by prefix letter:

PrefixSeriesMeaning
SSemanticCompile-time errors caught before execution (types, scope, syntax-adjacent rules).
RRuntimeErrors raised while the program is executing (VM, I/O, parsing).
DDatabaseCompile-time errors specific to database/table operations.

Extending the Registry

The registry lives entirely in src/errors.xcx, inside buildRegistry(). Each entry is a single pipe-delimited string:

$ text
_ ⛶ ×
1CODE|TITLE|SERIES|EXPLANATION|EXAMPLE

To add a new code, insert a new line following the existing pattern:

$ xcx
_ ⛶ ×
1reg.insert("S112", "S112|My new error|Semantic|Explanation goes here.|example.code(); --- S112");

src/lookup.xcx splits this string on | into a json entry with code, title, series, explanation, and example fields; src/format.xcx renders it to the terminal. No changes to either file are needed when adding new codes - only errors.xcx needs updating.

Notes

  • doc works fully offline; the registry is compiled into the binary at build time, not fetched at runtime.
  • Code lookup is case-insensitive and trims surrounding whitespace, so xcx doc s103, xcx doc S103, and xcx doc " S103 " all resolve identically.
  • Unknown codes never crash doc - they fall through to a graceful "unknown error code" message pointing to xcx doc list.