Skip to content

Commit 4e71782

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 5696223 commit 4e71782

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
@@ -317,20 +317,14 @@
317317
}
318318

319319
function tryGetCwd(path) {
320-
var threw = true;
321-
var cwd;
322320
try {
323-
cwd = process.cwd();
324-
threw = false;
325-
} finally {
326-
if (threw) {
327-
// getcwd(3) can fail if the current working directory has been deleted.
328-
// Fall back to the directory name of the (absolute) executable path.
329-
// It's not really correct but what are the alternatives?
330-
return path.dirname(process.execPath);
331-
}
321+
return process.cwd();
322+
} catch (ex) {
323+
// getcwd(3) can fail if the current working directory has been deleted.
324+
// Fall back to the directory name of the (absolute) executable path.
325+
// It's not really correct but what are the alternatives?
326+
return path.dirname(process.execPath);
332327
}
333-
return cwd;
334328
}
335329

336330
function evalScript(name) {

0 commit comments

Comments
 (0)