Skip to content

Commit

Permalink
lib: clean up usage of threw
Browse files Browse the repository at this point in the history
  • Loading branch information
JacksonTian committed Jan 2, 2017
1 parent ca82f72 commit 2b125c1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 20 deletions.
18 changes: 6 additions & 12 deletions lib/internal/bootstrap_node.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,20 +343,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
7 changes: 2 additions & 5 deletions lib/timers.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,13 +232,9 @@ function listOnTimeout() {
// 4.7) what is in this smaller function.
function tryOnTimeout(timer, list) {
timer._called = true;
var threw = true;
try {
ontimeout(timer);
threw = false;
} finally {
if (!threw) return;

} catch (ex) {
// We need to continue processing after domain error handling
// is complete, but not by using whatever domain was left over
// when the timeout threw its exception.
Expand All @@ -247,6 +243,7 @@ function tryOnTimeout(timer, list) {
// If we threw, we need to process the rest of the list in nextTick.
process.nextTick(listOnTimeoutNT, list);
process.domain = domain;
throw ex;
}
}

Expand Down
6 changes: 3 additions & 3 deletions test/message/timeout_throw.out
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
*test*message*timeout_throw.js:*
undefined_reference_error_maker;
^
timers.js:*
throw ex;
^
ReferenceError: undefined_reference_error_maker is not defined
at Timeout._onTimeout (*test*message*timeout_throw.js:*:*)
at ontimeout (timers.js:*:*)
Expand Down

0 comments on commit 2b125c1

Please sign in to comment.