Skip to content

Instantly share code, notes, and snippets.

@trashhalo
Last active August 29, 2015 14:22
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 trashhalo/9824c8de338af1bdfe6d to your computer and use it in GitHub Desktop.
Save trashhalo/9824c8de338af1bdfe6d to your computer and use it in GitHub Desktop.
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