Skip to content

Instantly share code, notes, and snippets.

@Azerothian
Created February 2, 2016 03:31
Show Gist options
  • Save Azerothian/ea17f5fde1467c08410b to your computer and use it in GitHub Desktop.
Save Azerothian/ea17f5fde1467c08410b to your computer and use it in GitHub Desktop.
function rejectOn4(v) {
if (v === 4) {
throw "crash";
}
}
function increment(v){
return v++;
}
function chain(v) {
return Promise.resolve(v)
.then(increment)
.then(rejectOn4);
}
Promise.resolve(1)
.then(chain)
.then(chain)
.then(chain)
.then(chain)
.then(chain)
.then(chain)
.then(() => {
console.log("success");
}, (err) => {
console.log("deal with it")
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment