repl: migrate errors to internal/errors

PR-URL: https://github.com/nodejs/node/pull/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>
This commit is contained in:
kysnm 2017-12-17 20:29:35 +09:00 committed by Jon Moss
parent 0b0a4fc8ec
commit ab5a2aba38
4 changed files with 12 additions and 4 deletions

View File

@ -1348,6 +1348,11 @@ The `REPL` module was unable parse data from the REPL history file.
An attempt was made to `require()` an [ES6 module][].
<a id="ERR_SCRIPT_EXECUTION_INTERRUPTED"></a>
### ERR_SCRIPT_EXECUTION_INTERRUPTED
Script execution was interrupted by `SIGINT` (For example, when Ctrl+C was pressed).
<a id="ERR_SERVER_ALREADY_LISTEN"></a>
### ERR_SERVER_ALREADY_LISTEN

View File

@ -445,6 +445,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`.');
E('ERR_SERVER_ALREADY_LISTEN',
'Listen method has been called more than once without closing.');
E('ERR_SOCKET_ALREADY_BOUND', 'Socket is already bound');

View File

@ -319,7 +319,7 @@ function REPLServer(prompt,
} catch (e) {
err = e;
if (err && err.message === 'Script execution interrupted.') {
if (err && err.code === 'ERR_SCRIPT_EXECUTION_INTERRUPTED') {
// The stack trace for this case is not very useful anyway.
Object.defineProperty(err, 'stack', { value: '' });
}
@ -339,7 +339,7 @@ function REPLServer(prompt,
if (self.breakEvalOnSigint) {
const interrupt = new Promise((resolve, reject) => {
sigintListener = () => {
reject(new Error('Script execution interrupted.'));
reject(new errors.Error('ERR_SCRIPT_EXECUTION_INTERRUPTED'));
};
prioritizedSigintQueue.add(sigintListener);
});
@ -358,7 +358,7 @@ function REPLServer(prompt,
// Remove prioritized SIGINT listener if it was not called.
prioritizedSigintQueue.delete(sigintListener);
if (err.message === 'Script execution interrupted.') {
if (err.code === 'ERR_SCRIPT_EXECUTION_INTERRUPTED') {
// The stack trace for this case is not very useful anyway.
Object.defineProperty(err, 'stack', { value: '' });
}

View File

@ -160,7 +160,8 @@ async function ctrlCTest() {
{ ctrl: true, name: 'c' }
]), [
'await timeout(100000)\r',
'Thrown: Error: Script execution interrupted.',
'Thrown: Error [ERR_SCRIPT_EXECUTION_INTERRUPTED]: ' +
'Script execution was interrupted by `SIGINT`.',
PROMPT
]);
}