Created
September 1, 2016 06:25
-
-
Save hjanuschka/45a86a1c078550e0d8836e3550108cd7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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