Skip to content

Instantly share code, notes, and snippets.

@deepal
Last active September 25, 2019 15:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save deepal/3e24b2dd0f5f9bf360b3b02a6a1e3b55 to your computer and use it in GitHub Desktop.
Save deepal/3e24b2dd0f5f9bf360b3b02a6a1e3b55 to your computer and use it in GitHub Desktop.
// Example 1
try {
return await myAsyncFunction();
} catch (err) {
// Any promise rejection while calling myAsyncFunction() will reach here, because of using `await`
}
// Example 2
try {
return myAsyncFunction();
} catch (err) {
// No promise rejection will reach here because the promise is returned to the caller instead of
// resolving it here.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment