Skip to content

Instantly share code, notes, and snippets.

@getify
Created March 2, 2014 16:55
Show Gist options
  • Save getify/9309531 to your computer and use it in GitHub Desktop.
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.
// 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
});
// ... 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