Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1e8bdab

Browse filesBrowse files
Trottdanielleadams
authored andcommitted
debugger: use ERR_DEBUGGER_STARTUP_ERROR in _inspect.js
PR-URL: #39024 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Jan Krems <jan.krems@gmail.com>
1 parent 3d7892e commit 1e8bdab
Copy full SHA for 1e8bdab

File tree

Expand file treeCollapse file tree

1 file changed

+3
-9
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+3
-9
lines changed
Open diff view settings
Collapse file

‎lib/internal/inspector/_inspect.js‎

Copy file name to clipboardExpand all lines: lib/internal/inspector/_inspect.js
+3-9Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ const {
88
ArrayPrototypePop,
99
ArrayPrototypeShift,
1010
ArrayPrototypeSlice,
11-
Error,
1211
FunctionPrototypeBind,
1312
Number,
1413
Promise,
@@ -46,12 +45,7 @@ const { 0: InspectClient, 1: createRepl } =
4645

4746
const debuglog = util.debuglog('inspect');
4847

49-
class StartupError extends Error {
50-
constructor(message) {
51-
super(message);
52-
this.name = 'StartupError';
53-
}
54-
}
48+
const { ERR_DEBUGGER_STARTUP_ERROR } = require('internal/errors').codes;
5549

5650
async function portIsFree(host, port, timeout = 9999) {
5751
if (port === 0) return; // Binding to a random port.
@@ -66,7 +60,7 @@ async function portIsFree(host, port, timeout = 9999) {
6660
while (true) {
6761
await asyncIterator.next();
6862
if (signal.aborted) {
69-
throw new StartupError( // eslint-disable-line no-restricted-syntax
63+
throw new ERR_DEBUGGER_STARTUP_ERROR(
7064
`Timeout (${timeout}) waiting for ${host}:${port} to be free`);
7165
}
7266
const error = await new Promise((resolve) => {
@@ -342,7 +336,7 @@ function startInspect(argv = ArrayPrototypeSlice(process.argv, 2),
342336
stdin.resume();
343337

344338
function handleUnexpectedError(e) {
345-
if (!(e instanceof StartupError)) {
339+
if (e.code !== 'ERR_DEBUGGER_STARTUP_ERROR') {
346340
console.error('There was an internal error in Node.js. ' +
347341
'Please report this bug.');
348342
console.error(e.message);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.