test: remove unused catch bindings
PR-URL: https://github.com/nodejs/node/pull/24079 Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: Wyatt Preul <wpreul@gmail.com>
This commit is contained in:
parent
a7ba5faaf5
commit
a74b4a062f
@ -372,7 +372,7 @@ function canCreateSymLink() {
|
||||
try {
|
||||
const output = execSync(`${whoamiPath} /priv`, { timout: 1000 });
|
||||
return output.includes('SeCreateSymbolicLinkPrivilege');
|
||||
} catch (e) {
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -456,7 +456,7 @@ function isAlive(pid) {
|
||||
try {
|
||||
process.kill(pid, 'SIGCONT');
|
||||
return true;
|
||||
} catch (e) {
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -665,7 +665,7 @@ function getTTYfd() {
|
||||
if (ttyFd === undefined) {
|
||||
try {
|
||||
return fs.openSync('/dev/tty');
|
||||
} catch (e) {
|
||||
} catch {
|
||||
// There aren't any tty fd's available to use.
|
||||
return -1;
|
||||
}
|
||||
@ -679,7 +679,7 @@ function runWithInvalidFD(func) {
|
||||
// be an valid one.
|
||||
try {
|
||||
while (fs.fstatSync(fd--) && fd > 0);
|
||||
} catch (e) {
|
||||
} catch {
|
||||
return func(fd);
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@ const common = require('../common');
|
||||
// The doctool currently uses js-yaml from the tool/node_modules/eslint/ tree.
|
||||
try {
|
||||
require('../../tools/node_modules/eslint/node_modules/js-yaml');
|
||||
} catch (e) {
|
||||
} catch {
|
||||
common.skip('missing js-yaml (eslint not present)');
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@ const common = require('../common');
|
||||
// The doctool currently uses js-yaml from the tool/node_modules/eslint/ tree.
|
||||
try {
|
||||
require('../../tools/node_modules/eslint/node_modules/js-yaml');
|
||||
} catch (e) {
|
||||
} catch {
|
||||
common.skip('missing js-yaml (eslint not present)');
|
||||
}
|
||||
|
||||
|
2
test/fixtures/catch-stdout-error.js
vendored
2
test/fixtures/catch-stdout-error.js
vendored
@ -22,7 +22,7 @@
|
||||
function write() {
|
||||
try {
|
||||
process.stdout.write('Hello, world\n');
|
||||
} catch (ex) {
|
||||
} catch {
|
||||
throw new Error('this should never happen');
|
||||
}
|
||||
setImmediate(function() {
|
||||
|
@ -182,7 +182,7 @@ if (process.argv[2] !== 'child') {
|
||||
const buf = messages[i++];
|
||||
|
||||
if (!buf) {
|
||||
try { sendSocket.close(); } catch (e) {}
|
||||
try { sendSocket.close(); } catch {}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -170,7 +170,7 @@ if (process.argv[2] !== 'child') {
|
||||
const buf = messages[i++];
|
||||
|
||||
if (!buf) {
|
||||
try { sendSocket.close(); } catch (e) {}
|
||||
try { sendSocket.close(); } catch {}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -40,12 +40,12 @@ tests.forEach((test) => {
|
||||
assert.strictEqual(test.pathname, parsed.pathname || '/');
|
||||
assert.strictEqual(test.search, parsed.search || '');
|
||||
assert.strictEqual(test.hash, parsed.hash || '');
|
||||
} catch (err) {
|
||||
} catch {
|
||||
// For now, we're just interested in the number of failures.
|
||||
failed++;
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
} catch {
|
||||
// If Parse failed and it wasn't supposed to, treat it as a failure.
|
||||
if (!test.failure)
|
||||
failed++;
|
||||
|
@ -30,7 +30,7 @@ try {
|
||||
filename: 'test.vm',
|
||||
displayErrors: false
|
||||
});
|
||||
} catch (e) {}
|
||||
} catch {}
|
||||
|
||||
console.error('middle');
|
||||
|
||||
|
@ -30,7 +30,7 @@ try {
|
||||
filename: 'test.vm',
|
||||
displayErrors: false
|
||||
});
|
||||
} catch (e) {}
|
||||
} catch {}
|
||||
|
||||
console.error('middle');
|
||||
|
||||
|
@ -168,7 +168,7 @@ assert.throws(
|
||||
},
|
||||
Array
|
||||
);
|
||||
} catch (e) {
|
||||
} catch {
|
||||
threw = true;
|
||||
}
|
||||
assert.ok(threw, 'wrong constructor validation');
|
||||
|
@ -168,13 +168,13 @@ testCipher2(Buffer.from('0123456789abcdef'));
|
||||
// not assert. See https://github.com/nodejs/node-v0.x-archive/issues/4886.
|
||||
{
|
||||
const c = crypto.createCipher('aes-256-cbc', 'secret');
|
||||
try { c.final('xxx'); } catch (e) { /* Ignore. */ }
|
||||
try { c.final('xxx'); } catch (e) { /* Ignore. */ }
|
||||
try { c.final('xxx'); } catch (e) { /* Ignore. */ }
|
||||
try { c.final('xxx'); } catch { /* Ignore. */ }
|
||||
try { c.final('xxx'); } catch { /* Ignore. */ }
|
||||
try { c.final('xxx'); } catch { /* Ignore. */ }
|
||||
const d = crypto.createDecipher('aes-256-cbc', 'secret');
|
||||
try { d.final('xxx'); } catch (e) { /* Ignore. */ }
|
||||
try { d.final('xxx'); } catch (e) { /* Ignore. */ }
|
||||
try { d.final('xxx'); } catch (e) { /* Ignore. */ }
|
||||
try { d.final('xxx'); } catch { /* Ignore. */ }
|
||||
try { d.final('xxx'); } catch { /* Ignore. */ }
|
||||
try { d.final('xxx'); } catch { /* Ignore. */ }
|
||||
}
|
||||
|
||||
// Regression test for https://github.com/nodejs/node-v0.x-archive/issues/5482:
|
||||
|
@ -56,7 +56,7 @@ process.on('exit', function() {
|
||||
function removeTestFile() {
|
||||
try {
|
||||
fs.unlinkSync(filepath);
|
||||
} catch (e) {}
|
||||
} catch {}
|
||||
}
|
||||
|
||||
|
||||
|
@ -22,7 +22,7 @@ for (const code of [
|
||||
if (require('fs').realpathSync('/dev/stdin')) {
|
||||
process.exit(2);
|
||||
}
|
||||
} catch (e) {
|
||||
} catch {
|
||||
process.exit(1);
|
||||
}`
|
||||
]) {
|
||||
|
@ -100,7 +100,7 @@ function test_simple_relative_symlink(realpath, realpathSync, callback) {
|
||||
[
|
||||
[entry, `../${path.basename(tmpDir)}/cycles/root.js`]
|
||||
].forEach(function(t) {
|
||||
try { fs.unlinkSync(t[0]); } catch (e) {}
|
||||
try { fs.unlinkSync(t[0]); } catch {}
|
||||
console.log('fs.symlinkSync(%j, %j, %j)', t[1], t[0], 'file');
|
||||
fs.symlinkSync(t[1], t[0], 'file');
|
||||
unlink.push(t[0]);
|
||||
@ -126,7 +126,7 @@ function test_simple_absolute_symlink(realpath, realpathSync, callback) {
|
||||
[
|
||||
[entry, expected]
|
||||
].forEach(function(t) {
|
||||
try { fs.unlinkSync(t[0]); } catch (e) {}
|
||||
try { fs.unlinkSync(t[0]); } catch {}
|
||||
console.error('fs.symlinkSync(%j, %j, %j)', t[1], t[0], type);
|
||||
fs.symlinkSync(t[1], t[0], type);
|
||||
unlink.push(t[0]);
|
||||
@ -151,13 +151,13 @@ function test_deep_relative_file_symlink(realpath, realpathSync, callback) {
|
||||
expected);
|
||||
const linkPath1 = path.join(targetsAbsDir,
|
||||
'nested-index', 'one', 'symlink1.js');
|
||||
try { fs.unlinkSync(linkPath1); } catch (e) {}
|
||||
try { fs.unlinkSync(linkPath1); } catch {}
|
||||
fs.symlinkSync(linkData1, linkPath1, 'file');
|
||||
|
||||
const linkData2 = '../one/symlink1.js';
|
||||
const entry = path.join(targetsAbsDir,
|
||||
'nested-index', 'two', 'symlink1-b.js');
|
||||
try { fs.unlinkSync(entry); } catch (e) {}
|
||||
try { fs.unlinkSync(entry); } catch {}
|
||||
fs.symlinkSync(linkData2, entry, 'file');
|
||||
unlink.push(linkPath1);
|
||||
unlink.push(entry);
|
||||
@ -178,13 +178,13 @@ function test_deep_relative_dir_symlink(realpath, realpathSync, callback) {
|
||||
const path1b = path.join(targetsAbsDir, 'nested-index', 'one');
|
||||
const linkPath1b = path.join(path1b, 'symlink1-dir');
|
||||
const linkData1b = path.relative(path1b, expected);
|
||||
try { fs.unlinkSync(linkPath1b); } catch (e) {}
|
||||
try { fs.unlinkSync(linkPath1b); } catch {}
|
||||
fs.symlinkSync(linkData1b, linkPath1b, 'dir');
|
||||
|
||||
const linkData2b = '../one/symlink1-dir';
|
||||
const entry = path.join(targetsAbsDir,
|
||||
'nested-index', 'two', 'symlink12-dir');
|
||||
try { fs.unlinkSync(entry); } catch (e) {}
|
||||
try { fs.unlinkSync(entry); } catch {}
|
||||
fs.symlinkSync(linkData2b, entry, 'dir');
|
||||
unlink.push(linkPath1b);
|
||||
unlink.push(entry);
|
||||
@ -208,7 +208,7 @@ function test_cyclic_link_protection(realpath, realpathSync, callback) {
|
||||
[path.join(tmpDir, '/cycles/realpath-3b'), '../cycles/realpath-3c'],
|
||||
[path.join(tmpDir, '/cycles/realpath-3c'), '../cycles/realpath-3a']
|
||||
].forEach(function(t) {
|
||||
try { fs.unlinkSync(t[0]); } catch (e) {}
|
||||
try { fs.unlinkSync(t[0]); } catch {}
|
||||
fs.symlinkSync(t[1], t[0], 'dir');
|
||||
unlink.push(t[0]);
|
||||
});
|
||||
@ -235,7 +235,7 @@ function test_cyclic_link_overprotection(realpath, realpathSync, callback) {
|
||||
const link = `${folder}/cycles`;
|
||||
let testPath = cycles;
|
||||
testPath += '/folder/cycles'.repeat(10);
|
||||
try { fs.unlinkSync(link); } catch (ex) {}
|
||||
try { fs.unlinkSync(link); } catch {}
|
||||
fs.symlinkSync(cycles, link, 'dir');
|
||||
unlink.push(link);
|
||||
assertEqualPath(realpathSync(testPath), path.resolve(expected));
|
||||
@ -263,7 +263,7 @@ function test_relative_input_cwd(realpath, realpathSync, callback) {
|
||||
].forEach(function(t) {
|
||||
const fn = t[0];
|
||||
console.error('fn=%j', fn);
|
||||
try { fs.unlinkSync(fn); } catch (e) {}
|
||||
try { fs.unlinkSync(fn); } catch {}
|
||||
const b = path.basename(t[1]);
|
||||
const type = (b === 'root.js' ? 'file' : 'dir');
|
||||
console.log('fs.symlinkSync(%j, %j, %j)', t[1], fn, type);
|
||||
@ -302,8 +302,8 @@ function test_deep_symlink_mix(realpath, realpathSync, callback) {
|
||||
$tmpDir/targets/cycles/root.js (hard)
|
||||
*/
|
||||
const entry = tmp('node-test-realpath-f1');
|
||||
try { fs.unlinkSync(tmp('node-test-realpath-d2/foo')); } catch (e) {}
|
||||
try { fs.rmdirSync(tmp('node-test-realpath-d2')); } catch (e) {}
|
||||
try { fs.unlinkSync(tmp('node-test-realpath-d2/foo')); } catch {}
|
||||
try { fs.rmdirSync(tmp('node-test-realpath-d2')); } catch {}
|
||||
fs.mkdirSync(tmp('node-test-realpath-d2'), 0o700);
|
||||
try {
|
||||
[
|
||||
@ -318,7 +318,7 @@ function test_deep_symlink_mix(realpath, realpathSync, callback) {
|
||||
[`${targetsAbsDir}/nested-index/two/realpath-c`,
|
||||
`${tmpDir}/cycles/root.js`]
|
||||
].forEach(function(t) {
|
||||
try { fs.unlinkSync(t[0]); } catch (e) {}
|
||||
try { fs.unlinkSync(t[0]); } catch {}
|
||||
fs.symlinkSync(t[1], t[0]);
|
||||
unlink.push(t[0]);
|
||||
});
|
||||
@ -429,14 +429,14 @@ function test_abs_with_kids(realpath, realpathSync, cb) {
|
||||
['/a/b/c/x.txt',
|
||||
'/a/link'
|
||||
].forEach(function(file) {
|
||||
try { fs.unlinkSync(root + file); } catch (ex) {}
|
||||
try { fs.unlinkSync(root + file); } catch {}
|
||||
});
|
||||
['/a/b/c',
|
||||
'/a/b',
|
||||
'/a',
|
||||
''
|
||||
].forEach(function(folder) {
|
||||
try { fs.rmdirSync(root + folder); } catch (ex) {}
|
||||
try { fs.rmdirSync(root + folder); } catch {}
|
||||
});
|
||||
}
|
||||
function setup() {
|
||||
|
@ -69,7 +69,7 @@ function test() {
|
||||
process.kill(child.pid, 'SIGKILL');
|
||||
try {
|
||||
parent.kill();
|
||||
} catch (e) {}
|
||||
} catch {}
|
||||
|
||||
assert.strictEqual(s, 'hello from child\n');
|
||||
assert.strictEqual(res.statusCode, 200);
|
||||
|
@ -69,7 +69,7 @@ function test() {
|
||||
process.kill(child.pid, 'SIGKILL');
|
||||
try {
|
||||
parent.kill();
|
||||
} catch (e) {}
|
||||
} catch {}
|
||||
|
||||
assert.strictEqual(s, 'hello from child\n');
|
||||
assert.strictEqual(res.statusCode, 200);
|
||||
|
@ -34,7 +34,7 @@ let invalidFd = 2;
|
||||
// Get first known bad file descriptor.
|
||||
try {
|
||||
while (fs.fstatSync(++invalidFd));
|
||||
} catch (e) {
|
||||
} catch {
|
||||
// do nothing; we now have an invalid fd
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ if (common.isWindows) {
|
||||
try {
|
||||
// If MUI != 'en' we'll ignore the content of the message
|
||||
localeOk = execSync(powerShellFindMUI).toString('utf8').trim() === 'en';
|
||||
} catch (_) {
|
||||
} catch {
|
||||
// It's only a best effort try to find the MUI
|
||||
}
|
||||
}
|
||||
|
@ -681,7 +681,7 @@ asyncTest('Throwing an error inside a rejectionHandled handler goes to' +
|
||||
setTimeout(function() {
|
||||
try {
|
||||
p.catch(function() {});
|
||||
} catch (e) {
|
||||
} catch {
|
||||
done(new Error('fail'));
|
||||
}
|
||||
}, 1);
|
||||
|
@ -63,7 +63,7 @@ function child() {
|
||||
let caught;
|
||||
try {
|
||||
vm.runInThisContext('haf!@##&$!@$*!@', { displayErrors: false });
|
||||
} catch (er) {
|
||||
} catch {
|
||||
caught = true;
|
||||
}
|
||||
assert(caught);
|
||||
|
@ -34,7 +34,7 @@ common.expectWarning('DeprecationWarning', deprecatedModules.map((m) => {
|
||||
for (const m of deprecatedModules) {
|
||||
try {
|
||||
require(m);
|
||||
} catch (err) {}
|
||||
} catch {}
|
||||
}
|
||||
|
||||
// Instead of checking require, check that resolve isn't pointing toward a
|
||||
|
@ -27,7 +27,7 @@ child.stderr.on('data', function(c) {
|
||||
child.on('close', common.mustCall(function(code) {
|
||||
try {
|
||||
output = JSON.parse(output);
|
||||
} catch (er) {
|
||||
} catch {
|
||||
console.error(output);
|
||||
process.exit(1);
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ function test(size, useBuffer, cb) {
|
||||
|
||||
try {
|
||||
fs.unlinkSync(tmpFile);
|
||||
} catch (e) {}
|
||||
} catch {}
|
||||
|
||||
console.log(`${size} chars to ${tmpFile}...`);
|
||||
|
||||
|
@ -6,7 +6,7 @@ const vm = require('vm');
|
||||
function a() {
|
||||
try {
|
||||
return a();
|
||||
} catch (e) {
|
||||
} catch {
|
||||
// Throw an exception as near to the recursion-based RangeError as possible.
|
||||
return vm.runInThisContext('() => 42')();
|
||||
}
|
||||
@ -17,7 +17,7 @@ assert.strictEqual(a(), 42);
|
||||
function b() {
|
||||
try {
|
||||
return b();
|
||||
} catch (e) {
|
||||
} catch {
|
||||
// This writes a lot of noise to stderr, but it still works.
|
||||
return vm.runInNewContext('() => 42')();
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ async function checkModuleState() {
|
||||
const m = new SourceTextModule('import "foo";');
|
||||
try {
|
||||
await m.link(common.mustCall(() => ({})));
|
||||
} catch (err) {
|
||||
} catch {
|
||||
assert.strictEqual(m.linkingStatus, 'errored');
|
||||
m.instantiate();
|
||||
}
|
||||
@ -219,7 +219,7 @@ async function checkLinking() {
|
||||
const erroredModule = new SourceTextModule('import "foo";');
|
||||
try {
|
||||
await erroredModule.link(common.mustCall(() => ({})));
|
||||
} catch (err) {
|
||||
} catch {
|
||||
// ignored
|
||||
} finally {
|
||||
assert.strictEqual(erroredModule.linkingStatus, 'errored');
|
||||
|
@ -7,8 +7,8 @@ const vm = require('vm');
|
||||
|
||||
try {
|
||||
new vm.Script({ toString() { throw new Error('foo'); } }, {});
|
||||
} catch (err) {}
|
||||
} catch {}
|
||||
|
||||
try {
|
||||
new vm.Script('[', {});
|
||||
} catch (err) {}
|
||||
} catch {}
|
||||
|
@ -31,13 +31,13 @@ const testsubdir = path.join(testDir, 'testsubdir');
|
||||
const filepath = path.join(testsubdir, 'watch.txt');
|
||||
|
||||
function cleanup() {
|
||||
try { fs.unlinkSync(filepath); } catch (e) { }
|
||||
try { fs.rmdirSync(testsubdir); } catch (e) { }
|
||||
try { fs.unlinkSync(filepath); } catch { }
|
||||
try { fs.rmdirSync(testsubdir); } catch { }
|
||||
}
|
||||
process.on('exit', cleanup);
|
||||
cleanup();
|
||||
|
||||
try { fs.mkdirSync(testsubdir, 0o700); } catch (e) {}
|
||||
try { fs.mkdirSync(testsubdir, 0o700); } catch {}
|
||||
|
||||
// Need a grace period, else the mkdirSync() above fires off an event.
|
||||
setTimeout(function() {
|
||||
|
@ -37,7 +37,7 @@ assert(ok, 'Run this test with --max_old_space_size=32.');
|
||||
const interval = setInterval(function() {
|
||||
try {
|
||||
vm.runInNewContext('throw 1;');
|
||||
} catch (e) {
|
||||
} catch {
|
||||
}
|
||||
|
||||
const rss = process.memoryUsage().rss;
|
||||
|
@ -25,7 +25,7 @@ do {
|
||||
try {
|
||||
script.runInContext(context, { timeout: 5 });
|
||||
++sandbox.timeout;
|
||||
} catch (err) {
|
||||
} catch {
|
||||
--sandbox.timeout;
|
||||
}
|
||||
} while (Date.now() < giveUp);
|
||||
|
@ -50,7 +50,7 @@ stream.on('finish', common.mustCall(function() {
|
||||
function destroy() {
|
||||
try {
|
||||
fs.unlinkSync(file);
|
||||
} catch (err) {
|
||||
} catch {
|
||||
// it may not exist
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user