Skip to content

fix: improve parse error display format#637

Open
bartlomieju wants to merge 5 commits intodenoland:mainfrom
bartlomieju:fix/improve-parse-error-display
Open

fix: improve parse error display format#637
bartlomieju wants to merge 5 commits intodenoland:mainfrom
bartlomieju:fix/improve-parse-error-display

Conversation

@bartlomieju
Copy link
Member

Summary

  • Reformats syntax error messages from ModuleErrorKind::Parse to use a structured format with location on its own line, pipe margins, line numbers, and carets
  • Removes the verbose "The module's source code could not be parsed:" prefix

Before:

The module's source code could not be parsed: Expected ',', got 'x' at file:///a.js:1:13

  import from "./foo.js"
              ~~~~~~~~~~

After:

Expected ',', got 'x'
    at file:///a.js:1:13
  |
1 | import from "./foo.js"
  |             ~~~~~~~~~~

Test plan

  • Updated snapshot test tests/specs/graph/cjs/file_export.txt
  • Updated JS test assertion in js/test.ts
  • All 210 deno_graph tests pass

🤖 Generated with Claude Code

Reformats syntax error messages to use a structured format with
location on its own line, pipe margins, line numbers, and carets
instead of the previous flat single-line format.

Before:
  The module's source code could not be parsed: Expected ',' got 'x' at file:///a.js:1:13

    import from "./foo.js"
                ~~~~~~~~~~

After:
  Expected ',' got 'x'
      at file:///a.js:1:13
    |
  1 | import from "./foo.js"
    |             ~~~~~~~~~~

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Member

@dsherret dsherret left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you do a ci run with this in the deno repo before merging?

@bartlomieju
Copy link
Member Author

Yeah, I opened denoland/deno#32669, but I'm not yet happy with the output

bartlomieju and others added 4 commits March 12, 2026 17:47
- Location line now appears after the code snippet instead of before
- String literal token descriptions simplified (e.g. 'string literal ("./foo.js", "./foo.js")' -> "./foo.js")

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants