From 213b6293fc0bbed36390e60fea96c84704539a40 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Sun, 4 Nov 2018 10:07:28 -0500 Subject: [PATCH] repl: remove unused catch bindings PR-URL: https://github.com/nodejs/node/pull/24079 Reviewed-By: Sam Roberts Reviewed-By: Wyatt Preul --- lib/repl.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/repl.js b/lib/repl.js index b752f5c67e6b9c..83ac339fdbb015 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -108,7 +108,7 @@ const kContextId = Symbol('contextId'); try { // Hack for require.resolve("./relative") to work properly. module.filename = path.resolve('repl'); -} catch (e) { +} catch { // path.resolve('repl') fails when the current working directory has been // deleted. Fall back to the directory name of the (absolute) executable // 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); try { files = fs.readdirSync(dir); - } catch (e) { + } catch { continue; } for (f = 0; f < files.length; f++) { @@ -1065,14 +1065,14 @@ function complete(line, callback) { abs = path.resolve(dir, name); try { isDirectory = fs.statSync(abs).isDirectory(); - } catch (e) { + } catch { continue; } if (isDirectory) { group.push(subdir + name + '/'); try { subfiles = fs.readdirSync(abs); - } catch (e) { + } catch { continue; } for (s = 0; s < subfiles.length; s++) { @@ -1154,13 +1154,13 @@ function complete(line, callback) { }); } } else { - const evalExpr = `try { ${expr} } catch (e) {}`; + const evalExpr = `try { ${expr} } catch {}`; this.eval(evalExpr, this.context, 'repl', (e, obj) => { if (obj != null) { if (typeof obj === 'object' || typeof obj === 'function') { try { memberGroups.push(filteredOwnPropertyNames.call(this, obj)); - } catch (ex) { + } catch { // Probably a Proxy object without `getOwnPropertyNames` trap. // We simply ignore it here, as we don't want to break the // autocompletion. Fixes the bug @@ -1185,7 +1185,7 @@ function complete(line, callback) { break; } } - } catch (e) {} + } catch {} } if (memberGroups.length) { @@ -1458,7 +1458,7 @@ function defineDefaultCommands(repl) { try { fs.writeFileSync(file, this.lines.join('\n') + '\n'); this.outputStream.write('Session saved to: ' + file + '\n'); - } catch (e) { + } catch { this.outputStream.write('Failed to save: ' + file + '\n'); } this.displayPrompt();