node/lib/internal/util/inspector.js
cjihrig fcb8bf1d35
inspector: remove unused catch bindings
PR-URL: https://github.com/nodejs/node/pull/24079
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Wyatt Preul <wpreul@gmail.com>
2018-11-06 10:59:00 -05:00

26 lines
521 B
JavaScript

'use strict';
const hasInspector = process.config.variables.v8_enable_inspector === 1;
const inspector = hasInspector ? require('inspector') : undefined;
let session;
function sendInspectorCommand(cb, onError) {
if (!hasInspector) return onError();
if (session === undefined) session = new inspector.Session();
try {
session.connect();
try {
return cb(session);
} finally {
session.disconnect();
}
} catch {
return onError();
}
}
module.exports = {
sendInspectorCommand
};