Last active
August 29, 2015 14:22
-
-
Save trashhalo/9824c8de338af1bdfe6d 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
function methodThatCleansUpStuff(){ | |
// dont return anything cause you are just cleaning up | |
} | |
function doAsyncStuff() { | |
return methodThatGivesAPromise() | |
.then(otherMethodThatGivesAPromise) | |
.then(()=>{throw new Error(“BOOM”)}) | |
.then(otherOtherMethodThatGivesAPromise) | |
.catch(methodThatCleansUpStuff) | |
} | |
doAsyncStuff().then(()=>{ | |
console.log('promise was resolved!!') | |
}) | |
.fail(()=>{ | |
console.log('promise was rejected!!') | |
}) | |
// this prints 'promise was resolved!!' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment