Skip to content

Commit 9129057

Browse files
JacksonTianMylesBorins
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 7678044 commit 9129057

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
@@ -430,20 +430,14 @@
430430
}
431431

432432
function tryGetCwd(path) {
433-
var threw = true;
434-
var cwd;
435433
try {
436-
cwd = process.cwd();
437-
threw = false;
438-
} finally {
439-
if (threw) {
440-
// getcwd(3) can fail if the current working directory has been deleted.
441-
// Fall back to the directory name of the (absolute) executable path.
442-
// It's not really correct but what are the alternatives?
443-
return path.dirname(process.execPath);
444-
}
434+
return process.cwd();
435+
} catch (ex) {
436+
// getcwd(3) can fail if the current working directory has been deleted.
437+
// Fall back to the directory name of the (absolute) executable path.
438+
// It's not really correct but what are the alternatives?
439+
return path.dirname(process.execPath);
445440
}
446-
return cwd;
447441
}
448442

449443
function evalScript(name) {

0 commit comments

Comments
 (0)