lib: clean up usage of threw · nodejs/node@4e71782

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) {