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:
Jackson Tian 2016-08-11 10:47:58 +08:00 committed by Ruben Bridgewater
parent 44d486500d
commit 67d792a74f
No known key found for this signature in database
GPG Key ID: F07496B3EB3C1762

View File

@ -466,21 +466,15 @@
} }
function tryGetCwd(path) { function tryGetCwd(path) {
var threw = true;
var cwd;
try { try {
cwd = process.cwd(); return process.cwd();
threw = false; } catch (ex) {
} finally {
if (threw) {
// getcwd(3) can fail if the current working directory has been deleted. // getcwd(3) can fail if the current working directory has been deleted.
// Fall back to the directory name of the (absolute) executable path. // Fall back to the directory name of the (absolute) executable path.
// It's not really correct but what are the alternatives? // It's not really correct but what are the alternatives?
return path.dirname(process.execPath); return path.dirname(process.execPath);
} }
} }
return cwd;
}
function evalScript(name) { function evalScript(name) {
const Module = NativeModule.require('module'); const Module = NativeModule.require('module');