Skip to content

Commit 38bb0d8

Browse files
TrottFishrock123
authored andcommittedNov 11, 2015
tools: Use throw new Error() consistently
In preparation for a lint rule that will enforce `throw new Error()` over `throw Error()`, fix the handful of instances in the code that use `throw Error()`. PR-URL: #3714 Reviewed-By: Evan Lucas <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Jeremiah Senkpiel <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 02e012e commit 38bb0d8

File tree

5 files changed

+6
-6
lines changed

5 files changed

+6
-6
lines changed
 

‎test/addons/make-callback/test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ assert.strictEqual(42, makeCallback(recv, 'two', 1337));
4040
const target = vm.runInNewContext(`
4141
(function($Object) {
4242
if (Object === $Object)
43-
throw Error('bad');
43+
throw new Error('bad');
4444
return Object;
4545
})
4646
`);
@@ -55,7 +55,7 @@ const forward = vm.runInNewContext(`
5555
// Runs in outer context.
5656
const endpoint = function($Object) {
5757
if (Object === $Object)
58-
throw Error('bad');
58+
throw new Error('bad');
5959
return Object;
6060
};
6161
assert.strictEqual(Object, makeCallback(process, forward, endpoint));

‎test/parallel/test-assert.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,6 @@ testBlockTypeError(assert.doesNotThrow, undefined);
465465

466466
// https://github.com/nodejs/node/issues/3275
467467
assert.throws(() => { throw 'error'; }, err => err === 'error');
468-
assert.throws(() => { throw Error(); }, err => err instanceof Error);
468+
assert.throws(() => { throw new Error(); }, err => err instanceof Error);
469469

470470
console.log('All OK');

‎test/parallel/test-http-mutable-headers.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ function nextTest() {
110110
break;
111111

112112
default:
113-
throw Error('?');
113+
throw new Error('?');
114114
}
115115

116116
response.setEncoding('utf8');

‎test/pummel/test-regress-GH-814.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ var timeToQuit = Date.now() + 8e3; //Test during no more than this seconds.
4646
}
4747
}
4848
else {
49-
throw Error("Buffer GC'ed test -> FAIL");
49+
throw new Error("Buffer GC'ed test -> FAIL");
5050
}
5151

5252
if (Date.now() < timeToQuit) {

‎test/pummel/test-regress-GH-814_2.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ function tailCB(data) {
2121
console.error('[FAIL]\n DATA -> ');
2222
console.error(data);
2323
console.error('\n');
24-
throw Error('Buffers GC test -> FAIL');
24+
throw new Error('Buffers GC test -> FAIL');
2525
}
2626
}
2727

0 commit comments

Comments
 (0)
Please sign in to comment.