Last active
August 29, 2015 13:57
-
-
Save stith/9905347 to your computer and use it in GitHub Desktop.
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
doStuff().then(function(things) { | |
if (!things) { | |
throw new Error("Here I want to skip everything else, including the 'then's after the next catch.."); | |
} | |
if (canMakeNewThing) { | |
// This should continue to the next 'then' | |
return someNewThing.save(); | |
} | |
return doSomeOtherThingsFirst().then(function(hold) { | |
return doMoreOtherThings(); // Should continue to the next 'then' | |
}).catch(function(err) { | |
throw new Error("This should skip the remaining thens as well.."); | |
}); | |
}, function(err) { | |
throw new Error(); // Skip the next then. | |
}).then(function() { | |
req.flash('success', 'Reserved!'); | |
res.redirect('/blah'); | |
}, function(err) { | |
console.log("Bailed.", err.stack); | |
// Don't do any rendering here, this is where errors go. | |
}); |
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
var things = yield doStuff(); | |
if (!things) { | |
throw new Error("easy"); | |
} | |
if (canMakeNewThing) { | |
var newThing = yield someNewThing.save(); | |
} | |
yield doSomeOtherThingsFirst(); | |
yield doMoreOtherThings(); | |
req.flash('success', 'Woot!'); | |
res.redirect('/blah'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment