Skip to content

Commit

Permalink
lib: clean up usage of threw
Browse files Browse the repository at this point in the history
Use try/catch to instead of threw.

PR-URL: nodejs#10534
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information
JacksonTian authored and cjihrig committed Aug 30, 2017
1 parent 904487f commit 73346f5
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions lib/internal/bootstrap_node.js
Original file line number Diff line number Diff line change
Expand Up @@ -466,20 +466,14 @@
}

function tryGetCwd(path) {
var threw = true;
var cwd;
try {
cwd = process.cwd();
threw = false;
} finally {
if (threw) {
// getcwd(3) can fail if 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?
return path.dirname(process.execPath);
}
return process.cwd();
} catch (ex) {
// getcwd(3) can fail if 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?
return path.dirname(process.execPath);
}
return cwd;
}

function evalScript(name) {
Expand Down

0 comments on commit 73346f5

Please sign in to comment.