Skip to content

Instantly share code, notes, and snippets.

@qoobaa
Created March 27, 2012 14:28
Show Gist options
  • Save qoobaa/2216396 to your computer and use it in GitHub Desktop.
Save qoobaa/2216396 to your computer and use it in GitHub Desktop.
var waitForError = function (expectedError, done) {
var originalExceptionListener = process.listeners("uncaughtException").pop();
process.once("uncaughtException", function (error) {
process.listeners("uncaughtException").push(originalExceptionListener);
if (error instanceof expectedError) {
done();
} else {
process.nextTick(function () {
throw error;
});
}
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment