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
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>
  • Loading branch information
Trott authored and danielleadams committed Jun 21, 2021
1 parent 3d7892e commit 1e8bdab
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 1e8bdab

Please sign in to comment.