module: print nicer error message on syntax error#17281
Merged
bnoordhuis merged 1 commit intonodejs:masterfrom Nov 29, 2017
Merged
module: print nicer error message on syntax error#17281bnoordhuis merged 1 commit intonodejs:masterfrom
bnoordhuis merged 1 commit intonodejs:masterfrom
Conversation
bnoordhuis
commented
Nov 24, 2017
src/module_wrap.cc
Outdated
Member
Author
There was a problem hiding this comment.
I could just use FATAL_ERROR here and undo the change to node_internals.h but I figured it might be nice to distinguish between "normal" fatal errors and ones from the esm module loader.
cjihrig
approved these changes
Nov 24, 2017
evanlucas
approved these changes
Nov 24, 2017
targos
approved these changes
Nov 24, 2017
addaleax
approved these changes
Nov 26, 2017
Include the offending line in the output and underline the bad token. Before this commit, it printed "SyntaxError: Unexpected reserved word" without indicating where the syntax error is. Now it prints the line and underlines the offending token, like it does for syntax errors in CJS scripts. Minor changes are made to the test runner in order to support `*.mjs` files in test/message. Fixes: nodejs#17277 PR-URL: nodejs#17281 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
MylesBorins
pushed a commit
that referenced
this pull request
Dec 12, 2017
Include the offending line in the output and underline the bad token. Before this commit, it printed "SyntaxError: Unexpected reserved word" without indicating where the syntax error is. Now it prints the line and underlines the offending token, like it does for syntax errors in CJS scripts. Minor changes are made to the test runner in order to support `*.mjs` files in test/message. Fixes: #17277 PR-URL: #17281 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
MylesBorins
pushed a commit
that referenced
this pull request
Dec 12, 2017
Include the offending line in the output and underline the bad token. Before this commit, it printed "SyntaxError: Unexpected reserved word" without indicating where the syntax error is. Now it prints the line and underlines the offending token, like it does for syntax errors in CJS scripts. Minor changes are made to the test runner in order to support `*.mjs` files in test/message. Fixes: #17277 PR-URL: #17281 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
Merged
Member
|
Should this be backported to 8.x? If so could someone raise a backport PR, as this fails with: [01:39|% 98|+ 2017|- 0]: release esm_display_syntax_error.mjs match failed
line=5
expect=^\ \ \ \ at\ loaders\.set\ \(internal\/loader\/ModuleRequest\.js\:.*\:.*\)$
actual= at ModuleJob.loaders.set [as moduleProvider] (internal/loader/ModuleRequest.js:33:13)
=== release esm_display_syntax_error.mjs ===
Path: message/esm_display_syntax_error.mjs
(node:64175) ExperimentalWarning: The ESM module loader is experimental.
file:///build/gib/node/test/message/esm_display_syntax_error.mjs:3
await async () => 0;
^^^^^
SyntaxError: Unexpected reserved word
at ModuleJob.loaders.set [as moduleProvider] (internal/loader/ModuleRequest.js:33:13)
at <anonymous>
Command: out/Release/node --experimental-modules /build/gib/node/test/message/esm_display_syntax_error.mjs
[01:39|% 98|+ 2017|- 1]: release esm_display_syntax_error_module.mjs match failed
line=5
expect=^\ \ \ \ at\ loaders\.set\ \(internal\/loader\/ModuleRequest\.js\:.*\:.*\)$
actual= at ModuleJob.loaders.set [as moduleProvider] (internal/loader/ModuleRequest.js:33:13)
=== release esm_display_syntax_error_module.mjs ===
Path: message/esm_display_syntax_error_module.mjs
(node:64185) ExperimentalWarning: The ESM module loader is experimental.
file:///build/gib/node/test/fixtures/es-module-loaders/syntax-error.mjs:2
await async () => 0;
^^^^^
SyntaxError: Unexpected reserved word
at ModuleJob.loaders.set [as moduleProvider] (internal/loader/ModuleRequest.js:33:13)
at <anonymous>
Command: out/Release/node --experimental-modules /build/gib/node/test/message/esm_display_syntax_error_module.mjs |
targos
added a commit
to targos/node
that referenced
this pull request
Dec 20, 2017
Use the same approach as a previous PR to include the offending line in the output and underline imports of inexistent exports. Fixes: nodejs#17785 Refs: nodejs#17281
3 tasks
targos
added a commit
to targos/node
that referenced
this pull request
Dec 24, 2017
Use the same approach as a previous PR to include the offending line in the output and underline imports of inexistent exports. PR-URL: nodejs#17786 Fixes: nodejs#17785 Refs: nodejs#17281 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
MylesBorins
pushed a commit
that referenced
this pull request
Jan 8, 2018
Use the same approach as a previous PR to include the offending line in the output and underline imports of inexistent exports. PR-URL: #17786 Fixes: #17785 Refs: #17281 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
MylesBorins
pushed a commit
that referenced
this pull request
Jan 9, 2018
Use the same approach as a previous PR to include the offending line in the output and underline imports of inexistent exports. PR-URL: #17786 Fixes: #17785 Refs: #17281 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
MylesBorins
pushed a commit
that referenced
this pull request
Jan 9, 2018
Use the same approach as a previous PR to include the offending line in the output and underline imports of inexistent exports. PR-URL: #17786 Fixes: #17785 Refs: #17281 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Member
|
Not convinced that this needs to be backported to 8.x |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes: #17277
CI: https://ci.nodejs.org/job/node-test-pull-request/11682/