Skip to content

Commit

Permalink
debugger: use ERR_DEBUGGER_STARTUP_ERROR in _inspect.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Trott committed Jun 13, 2021
1 parent 2ed44d6 commit 44f2581
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions lib/internal/inspector/_inspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const {
ArrayPrototypePop,
ArrayPrototypeShift,
ArrayPrototypeSlice,
Error,
FunctionPrototypeBind,
Number,
Promise,
Expand Down Expand Up @@ -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.
Expand All @@ -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) => {
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 44f2581

Please sign in to comment.