Last active
September 27, 2017 22:35
-
-
Save s-taylor/c0b01dce2943efece13ce8b5c1a24412 to your computer and use it in GitHub Desktop.
Understanding async await - part 7
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
async function someFunc () { | |
// since we’re using await on someAsyncThing and the promise rejected | |
// this line will now throw it will throw `new Error('Boom')` | |
const result = await someAsyncThing(); | |
// this line will not execute | |
return result.value; | |
} | |
// externally we’ll get a rejected promise returned containing `Error('Boom')` | |
await someFunc(); | |
// But since we’re using await here, the rejected promise gets turned back | |
// into a thrown error, so the end result is someFunc will throw `Error('Boom')` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment