Skip to content

Instantly share code, notes, and snippets.

@schahriar
Last active January 14, 2018 08:40
Show Gist options
  • Select an option

  • Save schahriar/94573c2a088edbb77f6f7809b87f7b29 to your computer and use it in GitHub Desktop.

Select an option

Save schahriar/94573c2a088edbb77f6f7809b87f7b29 to your computer and use it in GitHub Desktop.
Try/Catch block complex #async-await #medium
const throwsLater = async () => {
await PromiseThatThrows('Some error');
};
async () => {
try {
// Note that without await
// the error will never be
// caught
await throwsLater;
} catch (error) {
console.log(error.message);
// Output: Some error
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment