lib: add missing new for errors lib/*.js

Not including `new` adds a useless frame and removes a potentially
useful frame.

PR-URL: https://github.com/iojs/io.js/pull/1246
Reviewed-By: Petka Antonov <petka_antonov@hotmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Brendan Ashworth <brendan.ashworth@me.com>
This commit is contained in:
Mayhem 2015-03-24 15:15:57 +01:00 committed by Brendan Ashworth
parent 7dd5e824be
commit 1832743e18
6 changed files with 11 additions and 10 deletions

View File

@ -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);

View File

@ -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;
}

View File

@ -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;

View File

@ -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;
}

View File

@ -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) {
@ -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');

View File

@ -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]);
}
/**