/** * Error Registry * Central error definition registry with template rendering and help URL generation. */ /** Error category determining error ID prefix */ export type ErrorCategory = 'lexer' | 'parse' | 'runtime' | 'check'; /** Error severity level */ export type ErrorSeverity = 'error' | 'warning'; /** * Example demonstrating an error condition. * Used in error documentation to show common scenarios. */ export interface ErrorExample { /** Description of the example scenario (max 100 characters) */ readonly description: string; /** Example code demonstrating the error (max 500 characters) */ readonly code: string; } /** * Canonical hyphen-form error IDs. Used as registry keys and surfaced in * formatted error messages. Keys are the underscore "atom" form. * * Conversion: * - Hyphen form (registry key, user-facing): `ERROR_IDS.RILL_R003 === 'RILL-R003'` * - Atom form (rill atom code, e.g. `:rill_r003`): `ERROR_ATOMS[ERROR_IDS.RILL_R003] === 'RILL_R003'` * * Add a new ID by adding a key here AND a corresponding entry in * `ERROR_DEFINITIONS`. Both sides are validated at module load. */ export declare const ERROR_IDS: { readonly RILL_L001: 'RILL-L001'; readonly RILL_L002: 'RILL-L002'; readonly RILL_L003: 'RILL-L003'; readonly RILL_L004: 'RILL-L004'; readonly RILL_L005: 'RILL-L005'; readonly RILL_P001: 'RILL-P001'; readonly RILL_P002: 'RILL-P002'; readonly RILL_P003: 'RILL-P003'; readonly RILL_P004: 'RILL-P004'; readonly RILL_P005: 'RILL-P005'; readonly RILL_P006: 'RILL-P006'; readonly RILL_P007: 'RILL-P007'; readonly RILL_P008: 'RILL-P008'; readonly RILL_P009: 'RILL-P009'; readonly RILL_P010: 'RILL-P010'; readonly RILL_P011: 'RILL-P011'; readonly RILL_P012: 'RILL-P012'; readonly RILL_P014: 'RILL-P014'; readonly RILL_P015: 'RILL-P015'; readonly RILL_P020: 'RILL-P020'; readonly RILL_P021: 'RILL-P021'; readonly RILL_P022: 'RILL-P022'; readonly RILL_P023: 'RILL-P023'; readonly RILL_R001: 'RILL-R001'; readonly RILL_R002: 'RILL-R002'; readonly RILL_R003: 'RILL-R003'; readonly RILL_R005: 'RILL-R005'; readonly RILL_R006: 'RILL-R006'; readonly RILL_R007: 'RILL-R007'; readonly RILL_R008: 'RILL-R008'; readonly RILL_R009: 'RILL-R009'; readonly RILL_R010: 'RILL-R010'; readonly RILL_R011: 'RILL-R011'; readonly RILL_R012: 'RILL-R012'; readonly RILL_R013: 'RILL-R013'; readonly RILL_R014: 'RILL-R014'; readonly RILL_R015: 'RILL-R015'; readonly RILL_R016: 'RILL-R016'; readonly RILL_R017: 'RILL-R017'; readonly RILL_R018: 'RILL-R018'; readonly RILL_R019: 'RILL-R019'; readonly RILL_R020: 'RILL-R020'; readonly RILL_R021: 'RILL-R021'; readonly RILL_R022: 'RILL-R022'; readonly RILL_R023: 'RILL-R023'; readonly RILL_R024: 'RILL-R024'; readonly RILL_R025: 'RILL-R025'; readonly RILL_R026: 'RILL-R026'; readonly RILL_R027: 'RILL-R027'; readonly RILL_R028: 'RILL-R028'; readonly RILL_R029: 'RILL-R029'; readonly RILL_R030: 'RILL-R030'; readonly RILL_R031: 'RILL-R031'; readonly RILL_R032: 'RILL-R032'; readonly RILL_R033: 'RILL-R033'; readonly RILL_R034: 'RILL-R034'; readonly RILL_R035: 'RILL-R035'; readonly RILL_R036: 'RILL-R036'; readonly RILL_R037: 'RILL-R037'; readonly RILL_R038: 'RILL-R038'; readonly RILL_R039: 'RILL-R039'; readonly RILL_R040: 'RILL-R040'; readonly RILL_R041: 'RILL-R041'; readonly RILL_R042: 'RILL-R042'; readonly RILL_R043: 'RILL-R043'; readonly RILL_R044: 'RILL-R044'; readonly RILL_R045: 'RILL-R045'; readonly RILL_R050: 'RILL-R050'; readonly RILL_R051: 'RILL-R051'; readonly RILL_R052: 'RILL-R052'; readonly RILL_R053: 'RILL-R053'; readonly RILL_R054: 'RILL-R054'; readonly RILL_R055: 'RILL-R055'; readonly RILL_R056: 'RILL-R056'; readonly RILL_R057: 'RILL-R057'; readonly RILL_R058: 'RILL-R058'; readonly RILL_R059: 'RILL-R059'; readonly RILL_R060: 'RILL-R060'; readonly RILL_R061: 'RILL-R061'; readonly RILL_R062: 'RILL-R062'; readonly RILL_R063: 'RILL-R063'; readonly RILL_R064: 'RILL-R064'; readonly RILL_R065: 'RILL-R065'; readonly RILL_R066: 'RILL-R066'; readonly RILL_R067: 'RILL-R067'; readonly RILL_R068: 'RILL-R068'; readonly RILL_R069: 'RILL-R069'; readonly RILL_R070: 'RILL-R070'; readonly RILL_R071: 'RILL-R071'; readonly RILL_R072: 'RILL-R072'; readonly RILL_R073: 'RILL-R073'; readonly RILL_R074: 'RILL-R074'; readonly RILL_R075: 'RILL-R075'; readonly RILL_R076: 'RILL-R076'; readonly RILL_R077: 'RILL-R077'; readonly RILL_R078: 'RILL-R078'; readonly RILL_R079: 'RILL-R079'; readonly RILL_R080: 'RILL-R080'; readonly RILL_R081: 'RILL-R081'; readonly RILL_R082: 'RILL-R082'; readonly RILL_R083: 'RILL-R083'; readonly RILL_R084: 'RILL-R084'; readonly RILL_R085: 'RILL-R085'; readonly RILL_C001: 'RILL-C001'; readonly RILL_C002: 'RILL-C002'; readonly RILL_C003: 'RILL-C003'; readonly RILL_C004: 'RILL-C004'; }; /** Hyphen-form error ID (e.g. `'RILL-R003'`). */ export type ErrorId = (typeof ERROR_IDS)[keyof typeof ERROR_IDS]; /** Underscore atom-form error code (e.g. `'RILL_R003'`). */ type ErrorAtom = keyof typeof ERROR_IDS; /** Hyphen-form -> underscore atom-form map (`ERROR_ATOMS[ERROR_IDS.RILL_R003] === 'RILL_R003'`). */ export declare const ERROR_ATOMS: Readonly>; /** Error registry entry containing all metadata for a single error condition */ export interface ErrorDefinition { /** Format: RILL-{category}{3-digit} (e.g., RILL-R001) */ readonly errorId: ErrorId; /** Error category (determines ID prefix) */ readonly category: ErrorCategory; /** Severity level (defaults to 'error' when omitted) */ readonly severity?: ErrorSeverity | undefined; /** Human-readable description (max 50 characters) */ readonly description: string; /** Message template with {placeholder} syntax */ readonly messageTemplate: string; /** What causes this error (max 200 characters) */ readonly cause?: string | undefined; /** How to resolve this error (max 300 characters) */ readonly resolution?: string | undefined; /** Example scenarios demonstrating this error (max 3 entries) */ readonly examples?: ErrorExample[] | undefined; } /** * Central registry for all error definitions with O(1) lookup. * Immutable after initialization. */ export interface ErrorRegistry { get(errorId: string): ErrorDefinition | undefined; has(errorId: string): boolean; readonly size: number; entries(): IterableIterator<[string, ErrorDefinition]>; } export declare class ErrorRegistryImpl implements ErrorRegistry { private readonly byId; constructor(definitions: ErrorDefinition[]); get(errorId: string): ErrorDefinition | undefined; has(errorId: string): boolean; get size(): number; entries(): IterableIterator<[string, ErrorDefinition]>; } /** * Global error registry instance. * Read-only singleton initialized at module load. */ export declare const ERROR_REGISTRY: ErrorRegistry; /** * Renders a message template by replacing placeholders with context values. * * Placeholder format: {varName} * Missing context values render as empty string. * Non-string values are coerced via String(). * Invalid templates (unclosed braces) return template unchanged. * * @param template - Template string with {placeholder} syntax * @param context - Key-value pairs for placeholder replacement * @returns Rendered message with placeholders replaced * * @example * renderMessage("Expected {expected}, got {actual}", {expected: "string", actual: "number"}) * // Returns: "Expected string, got number" * * @example * renderMessage("Hello {name}", {}) * // Returns: "Hello " */ export declare function renderMessage(template: string, context: Record): string; /** * Generates documentation URL for an error ID. * * Format: https://github.com/rcrsr/rill/blob/v{version}/docs/ref-errors.md#{errorId} * Error ID is lowercased in anchor. * * @param errorId - Error identifier (format: RILL-{category}{3-digit}, e.g., RILL-R001) * @param version - Semver version (format: X.Y.Z) * @returns Documentation URL, or empty string if inputs are invalid * * @example * getHelpUrl("RILL-R001", "0.4.1") * // Returns: "https://github.com/rcrsr/rill/blob/v0.4.1/docs/ref-errors.md#rill-r001" * * @example * getHelpUrl("invalid", "0.4.1") * // Returns: "" */ export declare function getHelpUrl(errorId: string, version: string): string; export {};