Skip to content
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

Closed

Conversation

kysnm
Copy link
Contributor

@kysnm kysnm commented Dec 17, 2017

Refs: #17709

cc @jasnell @joyeecheung

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)

doc, errors, repl

@nodejs-github-bot nodejs-github-bot added errors Issues and PRs related to JavaScript errors originated in Node.js core. repl Issues and PRs related to the REPL subsystem. labels Dec 17, 2017
@kysnm
Copy link
Contributor Author

kysnm commented Dec 17, 2017

It is failed at test/async-hooks/test-callback-error.js on my local environment, but master branch also fails.

@Trott Trott added the semver-major PRs that contain breaking changes and should be released in the next major version. label Dec 17, 2017
@Trott
Copy link
Member

Trott commented Dec 17, 2017

@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.

CI: https://ci.nodejs.org/job/node-test-pull-request/12157/

@Trott
Copy link
Member

Trott commented Dec 17, 2017

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')) {
Copy link
Member

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(
Copy link
Member

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'),
Copy link
Member

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?

@joyeecheung
Copy link
Member

There are several tests that do incomplete matches against this error message, those should be updated as well, not necessarily in this PR though.

<a id="ERR_SCRIPT_EXECUTION_INTERRUPTED"></a>
### ERR_SCRIPT_EXECUTION_INTERRUPTED

A script execution interrupted.
Copy link
Member

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).

@kysnm
Copy link
Contributor Author

kysnm commented Dec 18, 2017

@joyeecheung
cc @jasnell

I have fixed as you pointed out. Please review.

@Trott
Copy link
Member

Trott commented Dec 18, 2017

Nit, just a suggestion, not a blocking objection: I think we should probably leave it at SIGINT and not add Cntl+C since there are other ways to send SIGINT that don't involve control+c.

@kysnm
Copy link
Contributor Author

kysnm commented Dec 18, 2017

@Trott
Thanks for your review. I almost agree with you. But, It is included Ctrl+C in a few docs. How do you think?
(I know. deps is almost irrelevant ...)

deps/v8/tools/testrunner/network/network_execution.py:        # Use a timeout so that signals (Ctrl+C) will be processed.
doc/api/vm.md:    `SIGINT` (Ctrl+C) is received. Existing handlers for the

<a id="ERR_SCRIPT_EXECUTION_INTERRUPTED"></a>
### ERR_SCRIPT_EXECUTION_INTERRUPTED

Script execution was interrupted by `SIGINT` (Ctrl+C).
Copy link
Member

@joyeecheung joyeecheung Dec 19, 2017

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

@@ -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).');
Copy link
Member

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.

@kysnm
Copy link
Contributor Author

kysnm commented Dec 19, 2017

@joyeecheung @Trott
cc @jasnell

Fixed!!

@joyeecheung
Copy link
Member

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

LGTM

@joyeecheung
Copy link
Member

Previous CI was stopped. New CI: https://ci.nodejs.org/job/node-test-pull-request/12257/

@joyeecheung joyeecheung added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Dec 22, 2017
@maclover7
Copy link
Contributor

Landing...

@maclover7 maclover7 self-assigned this Dec 22, 2017
@maclover7
Copy link
Contributor

Thank you for your contribution, landed in ab5a2ab.
❤️ 💚 💙 💛 💜

@maclover7 maclover7 closed this Dec 22, 2017
maclover7 pushed a commit to maclover7/node that referenced this pull request Dec 22, 2017
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>
@joyeecheung joyeecheung removed the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Dec 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
errors Issues and PRs related to JavaScript errors originated in Node.js core. repl Issues and PRs related to the REPL subsystem. semver-major PRs that contain breaking changes and should be released in the next major version.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants