Skip to content

Instantly share code, notes, and snippets.

@hjanuschka
Created September 1, 2016 06:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hjanuschka/45a86a1c078550e0d8836e3550108cd7 to your computer and use it in GitHub Desktop.
Save hjanuschka/45a86a1c078550e0d8836e3550108cd7 to your computer and use it in GitHub Desktop.
Promise.resolve()
.then(a("OK1"))
.then(a("OK2"))
.then(a("OK3"))
.then(a("OK4"))
.then(a("OK5"))
.then(a("DONE"))
.catch(function(e) {
console.log("ERROR");
});
function a(i) {
return new Promise(function(resolve, reject) {
setTimeout(function() {
if (i == "OK4") {
//console.log("THROW");
throw ('Error');
reject();
return;
}
if (i == "OK2") {
reject();
return;
}
console.log(i);
resolve();
}, 1000);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment