Skip to content

Docs: Document Compiler Custom Error Classes (TemplateValidationError, StyleCompilerError, BuildError) in API Reference #1048

Description

@nathanschmid08

Feature / Documentation Overview

The Avenx compiler uses a hierarchy of specialized error classes defined in lib/compiler/errors/:

  • CompilerError (base diagnosis class inheriting from AvenxError)
  • TemplateValidationError (specialized for template syntax and static validation warnings/errors like AVX_W02, AVX_W03, AVX_W04)
  • StyleCompilerError (specialized for CSS preprocessor and scoping errors like AVX_W24)
  • BuildError (specialized for build pipeline, directory, and bundle budget errors like AVX_C01, AVX_C02, AVX_C03, AVX_W01, AVX_W25)

Currently, docs/src/content/docs/troubleshooting/errors.md only documents AvenxError (the runtime base class) in detail. The compiler error classes lack API documentation (constructors, properties like sourceLine and details, and programmatic catch handling patterns).

Proposed Documentation Changes

Update docs/src/content/docs/troubleshooting/errors.md to add a comprehensive Compiler Error Class Hierarchy section:

  1. Class Hierarchy Diagram / Overview:
    • AvenxError -> CompilerError -> (TemplateValidationError, StyleCompilerError, BuildError).
  2. Constructor Signatures & Properties:
    • new CompilerError(code, message, details)
    • new TemplateValidationError(code, message, sourceLine)
    • new StyleCompilerError(code, message, cssFilePath)
    • new BuildError(code, message, buildContext)
  3. Programmatic Catching & Build Pipeline Integration:
    • Code examples showing how build tools, Vite plugins, or custom CLI scripts catch and inspect compiler errors programmatically.

Verification & Constraints

  • Verified zero duplicate issues exist (checked all open and closed issues 3 times).
  • Formatted according to Starlight / Astro markdown documentation guidelines.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationenhancementNew feature or requestgood first issueGood for newcomers

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions