Skip to content
This repository has been archived by the owner on Dec 2, 2018. It is now read-only.

Commit

Permalink
Make failing domain test pass.
Browse files Browse the repository at this point in the history
  • Loading branch information
domenic committed Dec 3, 2012
1 parent 1941453 commit 4a4a4a1
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions q.js
Original file line number Diff line number Diff line change
Expand Up @@ -1322,7 +1322,7 @@ function fin(promise, callback) {
exports.end = deprecate(done, "end", "done"); // XXX deprecated, use done
exports.done = done;
function done(promise, fulfilled, rejected, progress) {
function onUnhandledError(error) {
var onUnhandledError = function (error) {
// forward to a future turn so that ``when``
// does not catch it and turn it into a rejection.
nextTick(function () {
Expand All @@ -1334,13 +1334,16 @@ function done(promise, fulfilled, rejected, progress) {
throw error;
}
});
}
};

// Avoid unnecessary `nextTick`ing via an unnecessary `when`.
var promiseToHandle = fulfilled || rejected || progress ?
when(promise, fulfilled, rejected, progress) :
promise;

if (typeof process === "object" && process && process.domain) {
onUnhandledError = process.domain.bind(onUnhandledError);
}
fail(promiseToHandle, onUnhandledError);
}

Expand Down

0 comments on commit 4a4a4a1

Please sign in to comment.