lib: clean up usage of threw
Use try/catch to instead of threw. PR-URL: https://github.com/nodejs/node/pull/10534 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
parent
44d486500d
commit
67d792a74f
18
lib/internal/bootstrap_node.js
vendored
18
lib/internal/bootstrap_node.js
vendored
@ -466,20 +466,14 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function tryGetCwd(path) {
|
function tryGetCwd(path) {
|
||||||
var threw = true;
|
|
||||||
var cwd;
|
|
||||||
try {
|
try {
|
||||||
cwd = process.cwd();
|
return process.cwd();
|
||||||
threw = false;
|
} catch (ex) {
|
||||||
} finally {
|
// getcwd(3) can fail if the current working directory has been deleted.
|
||||||
if (threw) {
|
// Fall back to the directory name of the (absolute) executable path.
|
||||||
// getcwd(3) can fail if the current working directory has been deleted.
|
// It's not really correct but what are the alternatives?
|
||||||
// Fall back to the directory name of the (absolute) executable path.
|
return path.dirname(process.execPath);
|
||||||
// It's not really correct but what are the alternatives?
|
|
||||||
return path.dirname(process.execPath);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return cwd;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function evalScript(name) {
|
function evalScript(name) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user