Created
December 22, 2019 16:47
-
-
Save Gfast2/1c71012c7509ba89dfaea9b06f390b74 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("original") | |
.then( | |
resolved => { | |
console.log(`Upper Promise resolved, message is "${resolved}"`); | |
throw "stage1 throw error"; // -> This thrown error will trigger the following then()'s rejected function, but not in this then()'s rejection. | |
return "stage1 succeed"; | |
}, | |
rejected => { | |
console.log(`Upper Promise rejected, message is "${rejected}"`); | |
// throw "stage1 failed" // -> will let the following then() receive a rejected Promise with this string | |
return "stage1 failed"; // -> will let the following then() receive a resolved Promise with this string | |
} | |
) | |
.then( | |
resolved => { | |
console.log(`Upper Promise resolved, message is "${resolved}"`); | |
return "stage2 succeed"; | |
}, | |
rejected => { | |
console.log(`Upper Promise rejected, message is "${rejected}"`); | |
return "stage2 failed"; | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment