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: https://github.com/nodejs/node/pull/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>
const target = vm.runInNewContext(`
(function($Object) {
if (Object === $Object)
- throw Error('bad');
+ throw new Error('bad');
return Object;
})
`);
// Runs in outer context.
const endpoint = function($Object) {
if (Object === $Object)
- throw Error('bad');
+ throw new Error('bad');
return Object;
};
assert.strictEqual(Object, makeCallback(process, forward, endpoint));
// https://github.com/nodejs/node/issues/3275
assert.throws(() => { throw 'error'; }, err => err === 'error');
-assert.throws(() => { throw Error(); }, err => err instanceof Error);
+assert.throws(() => { throw new Error(); }, err => err instanceof Error);
console.log('All OK');
break;
default:
- throw Error('?');
+ throw new Error('?');
}
response.setEncoding('utf8');
}
}
else {
- throw Error("Buffer GC'ed test -> FAIL");
+ throw new Error("Buffer GC'ed test -> FAIL");
}
if (Date.now() < timeToQuit) {
console.error('[FAIL]\n DATA -> ');
console.error(data);
console.error('\n');
- throw Error('Buffers GC test -> FAIL');
+ throw new Error('Buffers GC test -> FAIL');
}
}