repl: 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:
cjihrig 2018-11-04 10:07:28 -05:00
parent ab14ad1f9d
commit a7ba5faaf5
No known key found for this signature in database
GPG Key ID: 7434390BDBE9B9C5

View File

@ -108,7 +108,7 @@ const kContextId = Symbol('contextId');
try { try {
// Hack for require.resolve("./relative") to work properly. // Hack for require.resolve("./relative") to work properly.
module.filename = path.resolve('repl'); module.filename = path.resolve('repl');
} catch (e) { } catch {
// path.resolve('repl') fails when the current working directory has been // path.resolve('repl') fails when the current working directory has been
// deleted. Fall back to the directory name of the (absolute) executable // deleted. Fall back to the directory name of the (absolute) executable
// path. It's not really correct but what are the alternatives? // path. It's not really correct but what are the alternatives?
@ -1051,7 +1051,7 @@ function complete(line, callback) {
dir = path.resolve(paths[i], subdir); dir = path.resolve(paths[i], subdir);
try { try {
files = fs.readdirSync(dir); files = fs.readdirSync(dir);
} catch (e) { } catch {
continue; continue;
} }
for (f = 0; f < files.length; f++) { for (f = 0; f < files.length; f++) {
@ -1065,14 +1065,14 @@ function complete(line, callback) {
abs = path.resolve(dir, name); abs = path.resolve(dir, name);
try { try {
isDirectory = fs.statSync(abs).isDirectory(); isDirectory = fs.statSync(abs).isDirectory();
} catch (e) { } catch {
continue; continue;
} }
if (isDirectory) { if (isDirectory) {
group.push(subdir + name + '/'); group.push(subdir + name + '/');
try { try {
subfiles = fs.readdirSync(abs); subfiles = fs.readdirSync(abs);
} catch (e) { } catch {
continue; continue;
} }
for (s = 0; s < subfiles.length; s++) { for (s = 0; s < subfiles.length; s++) {
@ -1154,13 +1154,13 @@ function complete(line, callback) {
}); });
} }
} else { } else {
const evalExpr = `try { ${expr} } catch (e) {}`; const evalExpr = `try { ${expr} } catch {}`;
this.eval(evalExpr, this.context, 'repl', (e, obj) => { this.eval(evalExpr, this.context, 'repl', (e, obj) => {
if (obj != null) { if (obj != null) {
if (typeof obj === 'object' || typeof obj === 'function') { if (typeof obj === 'object' || typeof obj === 'function') {
try { try {
memberGroups.push(filteredOwnPropertyNames.call(this, obj)); memberGroups.push(filteredOwnPropertyNames.call(this, obj));
} catch (ex) { } catch {
// Probably a Proxy object without `getOwnPropertyNames` trap. // Probably a Proxy object without `getOwnPropertyNames` trap.
// We simply ignore it here, as we don't want to break the // We simply ignore it here, as we don't want to break the
// autocompletion. Fixes the bug // autocompletion. Fixes the bug
@ -1185,7 +1185,7 @@ function complete(line, callback) {
break; break;
} }
} }
} catch (e) {} } catch {}
} }
if (memberGroups.length) { if (memberGroups.length) {
@ -1458,7 +1458,7 @@ function defineDefaultCommands(repl) {
try { try {
fs.writeFileSync(file, this.lines.join('\n') + '\n'); fs.writeFileSync(file, this.lines.join('\n') + '\n');
this.outputStream.write('Session saved to: ' + file + '\n'); this.outputStream.write('Session saved to: ' + file + '\n');
} catch (e) { } catch {
this.outputStream.write('Failed to save: ' + file + '\n'); this.outputStream.write('Failed to save: ' + file + '\n');
} }
this.displayPrompt(); this.displayPrompt();