Skip to content

Commit

Permalink
lib: add missing new for errors lib/*.js
Browse files Browse the repository at this point in the history
Not including `new` adds a useless frame and removes a potentially
useful frame.

PR-URL: #1246
Reviewed-By: Petka Antonov <petka_antonov@hotmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Brendan Ashworth <brendan.ashworth@me.com>
  • Loading branch information
nstepien authored and brendanashworth committed Mar 24, 2015
1 parent 7dd5e82 commit 1832743
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 10 deletions.
4 changes: 2 additions & 2 deletions lib/child_process.js
Expand Up @@ -860,9 +860,9 @@ function _validateStdio(stdio, sync) {
// Cleanup previously created pipes
cleanup();
if (!sync)
throw Error('Child process can have only one IPC pipe');
throw new Error('Child process can have only one IPC pipe');
else
throw Error('You cannot use IPC with synchronous forks');
throw new Error('You cannot use IPC with synchronous forks');
}

ipc = createPipe(true);
Expand Down
2 changes: 1 addition & 1 deletion lib/crypto.js
Expand Up @@ -548,7 +548,7 @@ ECDH.prototype.getPublicKey = function getPublicKey(encoding, format) {
else if (format === 'uncompressed')
f = constants.POINT_CONVERSION_UNCOMPRESSED;
else
throw TypeError('Bad format: ' + format);
throw new TypeError('Bad format: ' + format);
} else {
f = constants.POINT_CONVERSION_UNCOMPRESSED;
}
Expand Down
5 changes: 3 additions & 2 deletions lib/dns.js
Expand Up @@ -108,12 +108,13 @@ exports.lookup = function lookup(hostname, options, callback) {

// Parse arguments
if (hostname && typeof hostname !== 'string') {
throw TypeError('invalid arguments: hostname must be a string or falsey');
throw new TypeError('invalid arguments: ' +
'hostname must be a string or falsey');
} else if (typeof options === 'function') {
callback = options;
family = 0;
} else if (typeof callback !== 'function') {
throw TypeError('invalid arguments: callback must be passed');
throw new TypeError('invalid arguments: callback must be passed');
} else if (options !== null && typeof options === 'object') {
hints = options.hints >>> 0;
family = options.family >>> 0;
Expand Down
2 changes: 1 addition & 1 deletion lib/events.js
Expand Up @@ -140,7 +140,7 @@ EventEmitter.prototype.emit = function emit(type) {
} else if (er instanceof Error) {
throw er; // Unhandled 'error' event
} else {
throw Error('Uncaught, unspecified "error" event.');
throw new Error('Uncaught, unspecified "error" event.');
}
return false;
}
Expand Down
6 changes: 3 additions & 3 deletions lib/fs.js
Expand Up @@ -1628,12 +1628,12 @@ function ReadStream(path, options) {

if (this.start !== undefined) {
if (typeof this.start !== 'number') {
throw TypeError('start must be a Number');
throw new TypeError('start must be a Number');
}
if (this.end === undefined) {
this.end = Infinity;
} else if (typeof this.end !== 'number') {
throw TypeError('end must be a Number');
throw new TypeError('end must be a Number');
}

if (this.start > this.end) {
Expand Down Expand Up @@ -1790,7 +1790,7 @@ function WriteStream(path, options) {

if (this.start !== undefined) {
if (typeof this.start !== 'number') {
throw TypeError('start must be a Number');
throw new TypeError('start must be a Number');
}
if (this.start < 0) {
throw new Error('start must be >= zero');
Expand Down
2 changes: 1 addition & 1 deletion lib/punycode.js
Expand Up @@ -64,7 +64,7 @@
* @returns {Error} Throws a `RangeError` with the applicable error message.
*/
function error(type) {
throw RangeError(errors[type]);
throw new RangeError(errors[type]);
}

/**
Expand Down

0 comments on commit 1832743

Please sign in to comment.