diff --git a/lib/internal/inspector/_inspect.js b/lib/internal/inspector/_inspect.js index 204e037064daf2..e2309fcc68c268 100644 --- a/lib/internal/inspector/_inspect.js +++ b/lib/internal/inspector/_inspect.js @@ -8,7 +8,6 @@ const { ArrayPrototypePop, ArrayPrototypeShift, ArrayPrototypeSlice, - Error, FunctionPrototypeBind, Number, Promise, @@ -46,12 +45,7 @@ const { 0: InspectClient, 1: createRepl } = const debuglog = util.debuglog('inspect'); -class StartupError extends Error { - constructor(message) { - super(message); - this.name = 'StartupError'; - } -} +const { ERR_DEBUGGER_STARTUP_ERROR } = require('internal/errors').codes; async function portIsFree(host, port, timeout = 9999) { if (port === 0) return; // Binding to a random port. @@ -66,7 +60,7 @@ async function portIsFree(host, port, timeout = 9999) { while (true) { await asyncIterator.next(); if (signal.aborted) { - throw new StartupError( // eslint-disable-line no-restricted-syntax + throw new ERR_DEBUGGER_STARTUP_ERROR( `Timeout (${timeout}) waiting for ${host}:${port} to be free`); } const error = await new Promise((resolve) => { @@ -342,7 +336,7 @@ function startInspect(argv = ArrayPrototypeSlice(process.argv, 2), stdin.resume(); function handleUnexpectedError(e) { - if (!(e instanceof StartupError)) { + if (e.code !== 'ERR_DEBUGGER_STARTUP_ERROR') { console.error('There was an internal error in Node.js. ' + 'Please report this bug.'); console.error(e.message);