Skip to content

Instantly share code, notes, and snippets.

@s-taylor
Last active September 27, 2017 22:35
Show Gist options
  • Save s-taylor/c0b01dce2943efece13ce8b5c1a24412 to your computer and use it in GitHub Desktop.
Save s-taylor/c0b01dce2943efece13ce8b5c1a24412 to your computer and use it in GitHub Desktop.
Understanding async await - part 7
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