Skip to content

Commit 1832743

Browse files
nstepienbrendanashworth
authored andcommitted
lib: add missing new for errors lib/*.js
Not including `new` adds a useless frame and removes a potentially useful frame. PR-URL: #1246 Reviewed-By: Petka Antonov <[email protected]> Reviewed-By: Roman Reiss <[email protected]> Reviewed-By: Brendan Ashworth <[email protected]>
1 parent 7dd5e82 commit 1832743

File tree

6 files changed

+11
-10
lines changed

6 files changed

+11
-10
lines changed

lib/child_process.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -860,9 +860,9 @@ function _validateStdio(stdio, sync) {
860860
// Cleanup previously created pipes
861861
cleanup();
862862
if (!sync)
863-
throw Error('Child process can have only one IPC pipe');
863+
throw new Error('Child process can have only one IPC pipe');
864864
else
865-
throw Error('You cannot use IPC with synchronous forks');
865+
throw new Error('You cannot use IPC with synchronous forks');
866866
}
867867

868868
ipc = createPipe(true);

lib/crypto.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ ECDH.prototype.getPublicKey = function getPublicKey(encoding, format) {
548548
else if (format === 'uncompressed')
549549
f = constants.POINT_CONVERSION_UNCOMPRESSED;
550550
else
551-
throw TypeError('Bad format: ' + format);
551+
throw new TypeError('Bad format: ' + format);
552552
} else {
553553
f = constants.POINT_CONVERSION_UNCOMPRESSED;
554554
}

lib/dns.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,13 @@ exports.lookup = function lookup(hostname, options, callback) {
108108

109109
// Parse arguments
110110
if (hostname && typeof hostname !== 'string') {
111-
throw TypeError('invalid arguments: hostname must be a string or falsey');
111+
throw new TypeError('invalid arguments: ' +
112+
'hostname must be a string or falsey');
112113
} else if (typeof options === 'function') {
113114
callback = options;
114115
family = 0;
115116
} else if (typeof callback !== 'function') {
116-
throw TypeError('invalid arguments: callback must be passed');
117+
throw new TypeError('invalid arguments: callback must be passed');
117118
} else if (options !== null && typeof options === 'object') {
118119
hints = options.hints >>> 0;
119120
family = options.family >>> 0;

lib/events.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ EventEmitter.prototype.emit = function emit(type) {
140140
} else if (er instanceof Error) {
141141
throw er; // Unhandled 'error' event
142142
} else {
143-
throw Error('Uncaught, unspecified "error" event.');
143+
throw new Error('Uncaught, unspecified "error" event.');
144144
}
145145
return false;
146146
}

lib/fs.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1628,12 +1628,12 @@ function ReadStream(path, options) {
16281628

16291629
if (this.start !== undefined) {
16301630
if (typeof this.start !== 'number') {
1631-
throw TypeError('start must be a Number');
1631+
throw new TypeError('start must be a Number');
16321632
}
16331633
if (this.end === undefined) {
16341634
this.end = Infinity;
16351635
} else if (typeof this.end !== 'number') {
1636-
throw TypeError('end must be a Number');
1636+
throw new TypeError('end must be a Number');
16371637
}
16381638

16391639
if (this.start > this.end) {
@@ -1790,7 +1790,7 @@ function WriteStream(path, options) {
17901790

17911791
if (this.start !== undefined) {
17921792
if (typeof this.start !== 'number') {
1793-
throw TypeError('start must be a Number');
1793+
throw new TypeError('start must be a Number');
17941794
}
17951795
if (this.start < 0) {
17961796
throw new Error('start must be >= zero');

lib/punycode.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
* @returns {Error} Throws a `RangeError` with the applicable error message.
6565
*/
6666
function error(type) {
67-
throw RangeError(errors[type]);
67+
throw new RangeError(errors[type]);
6868
}
6969

7070
/**

0 commit comments

Comments
 (0)