-
Notifications
You must be signed in to change notification settings - Fork 30.6k
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
Changes from 1 commit
f237327
4f918bb
65fc1e8
fed6d47
3dcabb7
480358b
f142f84
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. I think you can check if |
||
// The stack trace for this case is not very useful anyway. | ||
Object.defineProperty(err, 'stack', { value: '' }); | ||
} | ||
|
@@ -335,7 +336,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); | ||
}); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe 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. |
||
errors.message('ERR_SCRIPT_EXECUTION_INTERRUPTED'), | ||
'Script execution interrupted.' | ||
); | ||
|
||
|
||
// Test that `code` property is mutable and that changing it does not change the | ||
// name. | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const errors = require('internal/errors'); | ||
const { stripVTControlCharacters } = require('internal/readline'); | ||
const repl = require('repl'); | ||
|
||
|
@@ -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 commentThe 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 |
||
PROMPT | ||
]); | ||
} | ||
|
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: