Skip to content

Instantly share code, notes, and snippets.

@deepal
Created April 27, 2019 13:48
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/71c964261dc72c75f226e40a71ad36e3 to your computer and use it in GitHub Desktop.
Save deepal/71c964261dc72c75f226e40a71ad36e3 to your computer and use it in GitHub Desktop.
function myAsyncFunction() {
return new Promise((resolve, reject) => {
setTimeout(() => {
reject(new Error('oops'))
}, 1000);
});
}
(async() => {
try {
await myAsyncFunction();
// happy path
} catch (err) {
// handle error
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment