7162: add line and column numbers to parse error messages#7333
7162: add line and column numbers to parse error messages#7333ashishjain0512 merged 2 commits intodevelopfrom
Conversation
on-behalf-of: @Mermaid-Chart <hello@mermaidchart.com>
🦋 Changeset detectedLatest commit: fd3fc50 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
✅ Deploy Preview for mermaid-js ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
@mermaid-js/examples
mermaid
@mermaid-js/layout-elk
@mermaid-js/layout-tidy-tree
@mermaid-js/mermaid-zenuml
@mermaid-js/parser
@mermaid-js/tiny
commit: |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #7333 +/- ##
==========================================
- Coverage 3.59% 3.59% -0.01%
==========================================
Files 474 474
Lines 47471 47489 +18
Branches 740 740
==========================================
Hits 1705 1705
- Misses 45766 45784 +18
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
The latest updates on your projects. Learn more about Argos notifications ↗︎
|
There was a problem hiding this comment.
Pull request overview
This PR enhances parser error reporting so that syntax and lexer errors across Mermaid diagram types include explicit line and column information, improving debugging and aligning with the behavior requested in issue #7162.
Changes:
- Updated
MermaidParseErrorto wrap lexer and parser errors with standardized, location-aware messages (Lexer error on line X, column Y:andParse error on line X, column Y:). - Added radar parser tests that validate the presence and formatting of line/column information in both lexer and parser error scenarios.
- Updated the info diagram tests to match the new error message format and added a changeset entry documenting the behavior change in
@mermaid-js/parser.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
packages/parser/src/parse.ts |
Centralizes error formatting in MermaidParseError to include line and column numbers for lexer and parser errors, affecting all diagram types that use the shared parser. |
packages/parser/tests/radar.test.ts |
Extends radar grammar tests to call the shared async parse API and assert that thrown MermaidParseError instances include line/column information and the standardized Parse error on line X, column Y prefix. |
packages/mermaid/src/diagrams/info/info.spec.ts |
Adjusts info diagram parser tests to assert the new lexer error message format including line and column metadata. |
.changeset/slow-bees-mate.md |
Records a patch-level changeset for @mermaid-js/parser describing the enhanced parser error messages for release notes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
📑 Summary
Enhanced the
MermaidParseErrorclass to include line and column numbers in all parser error messages, significantly improving debugging experience. Previously, syntax errors only showed generic messages without location information. Now all diagram types (radar, pie, info, packet, etc.) display errors in the format:Parse error on line X, column Y: <error details>. Added comprehensive tests to verify error formatting and updated existing tests to match the new format.Resolves #7162
📏 Design Decisions
Describe the way your implementation works or what design decisions you made if applicable.
📋 Tasks
Make sure you
MERMAID_RELEASE_VERSIONis used for all new features.pnpm changesetand following the prompts. Changesets that add features should beminorand those that fix bugs should bepatch. Please prefix changeset messages withfeat:,fix:, orchore:.