Skip to content

Commit 3d133eb

Browse files
jasnelladdaleax
authored andcommitted
util, debugger: remove internalUtil.error
The internalUtil.error() function was only used by _debugger.js. PR-URL: #11448 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent 95bee8f commit 3d133eb

File tree

3 files changed

+10
-29
lines changed

3 files changed

+10
-29
lines changed

lib/_debugger.js

+10-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
'use strict';
22

3-
const internalUtil = require('internal/util');
43
const util = require('util');
54
const path = require('path');
65
const net = require('net');
@@ -11,6 +10,11 @@ const inherits = util.inherits;
1110
const assert = require('assert');
1211
const spawn = require('child_process').spawn;
1312
const Buffer = require('buffer').Buffer;
13+
const prefix = `(${process.release.name}:${process.pid}) `;
14+
15+
function error(msg) {
16+
console.error(`${prefix}${msg}`);
17+
}
1418

1519
exports.start = function(argv, stdin, stdout) {
1620
argv || (argv = process.argv.slice(2));
@@ -32,8 +36,8 @@ exports.start = function(argv, stdin, stdout) {
3236
stdin.resume();
3337

3438
process.on('uncaughtException', function(e) {
35-
internalUtil.error('There was an internal error in Node\'s debugger. ' +
36-
'Please report this bug.');
39+
error('There was an internal error in Node\'s debugger. ' +
40+
'Please report this bug.');
3741
console.error(e.message);
3842
console.error(e.stack);
3943
if (interface_.child) interface_.child.kill();
@@ -521,7 +525,7 @@ Client.prototype.mirrorObject = function(handle, depth, cb) {
521525
cb = cb || function() {};
522526
this.reqLookup(propertyRefs, function(err, res) {
523527
if (err) {
524-
internalUtil.error('problem with reqLookup');
528+
error('problem with reqLookup');
525529
cb(null, handle);
526530
return;
527531
}
@@ -1672,7 +1676,7 @@ Interface.prototype.trySpawn = function(cb) {
16721676
process._debugProcess(pid);
16731677
} catch (e) {
16741678
if (e.code === 'ESRCH') {
1675-
internalUtil.error(`Target process: ${pid} doesn't exist.`);
1679+
error(`Target process: ${pid} doesn't exist.`);
16761680
process.exit(1);
16771681
}
16781682
throw e;
@@ -1741,7 +1745,7 @@ Interface.prototype.trySpawn = function(cb) {
17411745
function connectError() {
17421746
// If it's failed to connect 10 times then print failed message
17431747
if (connectionAttempts >= 10) {
1744-
internalUtil.error(' failed to connect, please retry');
1748+
error(' failed to connect, please retry');
17451749
process.exit(1);
17461750
}
17471751
setTimeout(attemptConnect, 500);

lib/internal/util.js

-13
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,6 @@ exports.deprecate = function(fn, msg) {
1616
return exports._deprecate(fn, msg);
1717
};
1818

19-
exports.error = function(msg) {
20-
const fmt = `${prefix}${msg}`;
21-
if (arguments.length > 1) {
22-
const args = new Array(arguments.length);
23-
args[0] = fmt;
24-
for (var i = 1; i < arguments.length; ++i)
25-
args[i] = arguments[i];
26-
console.error.apply(console, args);
27-
} else {
28-
console.error(fmt);
29-
}
30-
};
31-
3219
exports.trace = function(msg) {
3320
console.trace(`${prefix}${msg}`);
3421
};

test/parallel/test-util-internal.js

-10
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
const common = require('../common');
55
const path = require('path');
66
const assert = require('assert');
7-
const spawnSync = require('child_process').spawnSync;
87

98
const binding = process.binding('util');
109
const kArrowMessagePrivateSymbolIndex = binding['arrow_message_private_symbol'];
@@ -59,12 +58,3 @@ try {
5958
}
6059

6160
assert(/bad_syntax\.js:1/.test(arrowMessage));
62-
63-
const args = [
64-
'--expose-internals',
65-
'-e',
66-
"require('internal/util').error('foo %d', 5)"
67-
];
68-
const result = spawnSync(process.argv[0], args, { encoding: 'utf8' });
69-
assert.strictEqual(result.stderr.indexOf('%'), -1);
70-
assert(/foo 5/.test(result.stderr));

0 commit comments

Comments
 (0)