Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing new for errors lib/*.js #1246

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/child_process.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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