Skip to content

Implement Code Frames for Compiler Errors #39

@eugenioenko

Description

@eugenioenko

Description:
Currently, compiler errors (scanning and parsing) only show line and column numbers. To improve debugging, we should display a small snippet of the source code (a "code frame") with a pointer to the exact location of the
error.

Example Output:

   1   3 | <div>{{ 1 + }}</div>
   2     |             ^

Tasks:

  • Add source?: string to KasperError constructor.
  • Implement a generateCodeFrame utility in src/types/error.ts.
  • Update Scanner, Parser, and TemplateParser to pass the original source string when throwing errors.
  • Only show code frames in development mode.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions