Created
March 2, 2014 16:55
-
-
Save getify/9309531 to your computer and use it in GitHub Desktop.
no such thing as "silent errors" in asynquence, like there is with other promises' libs. So, asynquence doesn't need the hack of `done(..)` like others do.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// With asynquence, if an error occurs in an `or` callback, and you have | |
// no other `or(..)` callbacks registered that could be notified, it's | |
// just thrown as a normal uncaught global error. | |
ASQ() | |
.then(function(){ | |
done("foobar"); | |
}) | |
.or(function(msg){ | |
console.log(msg); // foobar | |
a.b; // ReferenceError: `a` is undefined | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ... but if you DO have another `or` callback registered, then the | |
// error gets added to the error stream so the subsequent `or(..)` | |
// callbacks will be notified. | |
ASQ() | |
.then(function(){ | |
done("foobar"); | |
}) | |
.or(function(err){ | |
console.log(err); // foobar | |
a.b; // ReferenceError: a is undefined | |
}) | |
.or(function(err1, err2){ | |
console.log("First error: " + err1); // First error: foobar | |
console.log("Second error: " + err2); // ReferenceError: a is undefined | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment