Skip to content

Instantly share code, notes, and snippets.

@zemuldo
Last active June 22, 2019 22:08
Show Gist options
  • Save zemuldo/1c51aaa11da3c4218324f5f26f4a1a45 to your computer and use it in GitHub Desktop.
Save zemuldo/1c51aaa11da3c4218324f5f26f4a1a45 to your computer and use it in GitHub Desktop.
Catch errors in a promise chain
function run (){
i_am_first_but_i_take_10_sec()
.then(() => {
return i_am_second_but_i_take_8_sec()
})
.then(() => {
return i_am_third_but_i_take_6_sec()
})
.then(() => {
return i_am_fourth_but_i_take_4_sec()
})
.then(() => {
return i_am_last_but_i_take_1_sec()
})
.then(() => {
console.log("Done")
})
.catch((error)=>{
console.log(error)
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment