Skip to content

Commit 67d792a

Browse files
JacksonTianBridgeAR
authored andcommitted
lib: clean up usage of threw
Use try/catch to instead of threw. PR-URL: #10534 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent 44d4865 commit 67d792a

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

lib/internal/bootstrap_node.js

+6-12
Original file line numberDiff line numberDiff line change
@@ -466,20 +466,14 @@
466466
}
467467

468468
function tryGetCwd(path) {
469-
var threw = true;
470-
var cwd;
471469
try {
472-
cwd = process.cwd();
473-
threw = false;
474-
} finally {
475-
if (threw) {
476-
// getcwd(3) can fail if the current working directory has been deleted.
477-
// Fall back to the directory name of the (absolute) executable path.
478-
// It's not really correct but what are the alternatives?
479-
return path.dirname(process.execPath);
480-
}
470+
return process.cwd();
471+
} catch (ex) {
472+
// getcwd(3) can fail if the current working directory has been deleted.
473+
// Fall back to the directory name of the (absolute) executable path.
474+
// It's not really correct but what are the alternatives?
475+
return path.dirname(process.execPath);
481476
}
482-
return cwd;
483477
}
484478

485479
function evalScript(name) {

0 commit comments

Comments
 (0)