Last active
June 22, 2019 22:08
-
-
Save zemuldo/1c51aaa11da3c4218324f5f26f4a1a45 to your computer and use it in GitHub Desktop.
Catch errors in a promise chain
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 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