Skip to content

Commit b7ee9d8

Browse files
Trottrichardlau
authored andcommitted
debugger: use ERR_DEBUGGER_STARTUP_ERROR in _inspect.js
PR-URL: #39024 Backport-PR-URL: #39446 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 9b993ed commit b7ee9d8

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

lib/internal/inspector/_inspect.js

+3-9
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,
@@ -50,12 +49,7 @@ const { 0: InspectClient, 1: createRepl } =
5049

5150
const debuglog = util.debuglog('inspect');
5251

53-
class StartupError extends Error {
54-
constructor(message) {
55-
super(message);
56-
this.name = 'StartupError';
57-
}
58-
}
52+
const { ERR_DEBUGGER_STARTUP_ERROR } = require('internal/errors').codes;
5953

6054
async function portIsFree(host, port, timeout = 9999) {
6155
if (port === 0) return; // Binding to a random port.
@@ -70,7 +64,7 @@ async function portIsFree(host, port, timeout = 9999) {
7064
while (true) {
7165
await asyncIterator.next();
7266
if (signal.aborted) {
73-
throw new StartupError( // eslint-disable-line no-restricted-syntax
67+
throw new ERR_DEBUGGER_STARTUP_ERROR(
7468
`Timeout (${timeout}) waiting for ${host}:${port} to be free`);
7569
}
7670
const error = await new Promise((resolve) => {
@@ -346,7 +340,7 @@ function startInspect(argv = ArrayPrototypeSlice(process.argv, 2),
346340
stdin.resume();
347341

348342
function handleUnexpectedError(e) {
349-
if (!(e instanceof StartupError)) {
343+
if (e.code !== 'ERR_DEBUGGER_STARTUP_ERROR') {
350344
console.error('There was an internal error in Node.js. ' +
351345
'Please report this bug.');
352346
console.error(e.message);

0 commit comments

Comments
 (0)