Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 38bb0d8

Browse filesBrowse files
TrottFishrock123
authored andcommitted
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 <evanlucas@me.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 02e012e commit 38bb0d8
Copy full SHA for 38bb0d8

File tree

Expand file treeCollapse file tree

5 files changed

+6
-6
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

5 files changed

+6
-6
lines changed
Open diff view settings
Collapse file

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

Copy file name to clipboardExpand all lines: test/addons/make-callback/test.js
+2-2Lines changed: 2 additions & 2 deletions
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));
Collapse file

‎test/parallel/test-assert.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-assert.js
+1-1Lines changed: 1 addition & 1 deletion
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');
Collapse file

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

Copy file name to clipboardExpand all lines: test/parallel/test-http-mutable-headers.js
+1-1Lines changed: 1 addition & 1 deletion
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');
Collapse file

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

Copy file name to clipboardExpand all lines: test/pummel/test-regress-GH-814.js
+1-1Lines changed: 1 addition & 1 deletion
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) {
Collapse file

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

Copy file name to clipboardExpand all lines: test/pummel/test-regress-GH-814_2.js
+1-1Lines changed: 1 addition & 1 deletion
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.