Skip to content

Commit

Permalink
Show an error if Node exits with rejection
Browse files Browse the repository at this point in the history
If there is at least one outstanding error when Node exits, throw that
error.

Fixes #115 as recommended by @tlrobinson.
  • Loading branch information
kriskowal committed Jan 27, 2013
1 parent 9d6921c commit d5f46b9
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion q.js
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,16 @@ function displayErrors() {
errorsDisplayed = true;
}

// Show unhandled rejection if Node exits without handling an outstanding
// rejection.
if (typeof process !== "undefined") {

This comment has been minimized.

Copy link
@domenic

domenic Jan 27, 2013

Collaborator

I'd suggest && process.on since browserify's process doesn't have an on.

This comment has been minimized.

Copy link
@kriskowal

kriskowal Jan 27, 2013

Author Owner

Ah, tricksy.

process.on("exit", function () {
if (errors.length) {
throw errors[0];
}
});
}

/**
* Constructs a rejected promise.
* @param exception value describing the failure
Expand All @@ -631,7 +641,7 @@ function reject(exception) {
rejections.splice(at, 1);
}
}
return rejected ? rejected(exception) : reject(exception);
return rejected ? rejected(exception) : this;
}
}, function fallback() {
return reject(exception);
Expand Down

0 comments on commit d5f46b9

Please sign in to comment.