-
Notifications
You must be signed in to change notification settings - Fork 29.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
repl: migrate errors to internal/errors #17716
Conversation
It is failed at test/async-hooks/test-callback-error.js on my local environment, but master branch also fails. |
@kysnm Sounds like you may be experiencing #15985 on your local machine. If you do any troubleshooting and find information that may be useful, please put it in that issue! (And if you find a fix for the problem, please submit a pull request!) Otherwise, yes, that is most likely unrelated to the change here. |
Pinging @nodejs/tsc since this will need two TSC approvals. |
lib/repl.js
Outdated
@@ -315,7 +315,8 @@ function REPLServer(prompt, | |||
} catch (e) { | |||
err = e; | |||
|
|||
if (err && err.message === 'Script execution interrupted.') { | |||
if (err && err.message === | |||
errors.message('ERR_SCRIPT_EXECUTION_INTERRUPTED')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can check if err.code === 'ERR_SCRIPT_EXECUTION_INTERRUPTED'
here instead (which is kinda the point of this PR, the code instead of the message should be used to match a type of error)
@@ -341,6 +341,13 @@ assert.strictEqual( | |||
); | |||
} | |||
|
|||
// Test ERR_SCRIPT_EXECUTION_INTERRUPTED | |||
assert.strictEqual( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test does not look particularly useful since the error message formatter does not take any parameters for this error.
@@ -160,7 +161,8 @@ async function ctrlCTest() { | |||
{ ctrl: true, name: 'c' } | |||
]), [ | |||
'await timeout(100000)\r', | |||
'Thrown: Error: Script execution interrupted.', | |||
'Thrown: Error [ERR_SCRIPT_EXECUTION_INTERRUPTED]: ' + | |||
errors.message('ERR_SCRIPT_EXECUTION_INTERRUPTED'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we are actually testing the error message, we don't really need to generate it with errors.message
, can you change this to match the actual error message instead?
There are several tests that do incomplete matches against this error message, those should be updated as well, not necessarily in this PR though. |
doc/api/errors.md
Outdated
<a id="ERR_SCRIPT_EXECUTION_INTERRUPTED"></a> | ||
### ERR_SCRIPT_EXECUTION_INTERRUPTED | ||
|
||
A script execution interrupted. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you elaborate a bit more on this? For example:
Script execution was interrupted by `SIGINT` (Ctrl+C).
I have fixed as you pointed out. Please review. |
Nit, just a suggestion, not a blocking objection: I think we should probably leave it at |
@Trott
|
doc/api/errors.md
Outdated
<a id="ERR_SCRIPT_EXECUTION_INTERRUPTED"></a> | ||
### ERR_SCRIPT_EXECUTION_INTERRUPTED | ||
|
||
Script execution was interrupted by `SIGINT` (Ctrl+C). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I kind of agree with @Trott that this is not exactly accurate. Maybe here we should say (for example, when Ctrl+C was pressed)
instead
lib/internal/errors.js
Outdated
@@ -440,6 +440,8 @@ E('ERR_OUTOFMEMORY', 'Out of memory'); | |||
E('ERR_OUT_OF_RANGE', 'The "%s" argument is out of range'); | |||
E('ERR_PARSE_HISTORY_DATA', 'Could not parse history data in %s'); | |||
E('ERR_REQUIRE_ESM', 'Must use import to load ES Module: %s'); | |||
E('ERR_SCRIPT_EXECUTION_INTERRUPTED', | |||
'Script execution was interrupted by `SIGINT` (Ctrl+C).'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably don't need the part in the parentheses in the error message. The details should be in the docs.
@joyeecheung @Trott Fixed!! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Previous CI was stopped. New CI: https://ci.nodejs.org/job/node-test-pull-request/12257/ |
Landing... |
Thank you for your contribution, landed in ab5a2ab. |
PR-URL: nodejs#17716 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Jon Moss <me@jonathanmoss.me> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Refs: #17709
cc @jasnell @joyeecheung
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
doc, errors, repl