Skip to content

Instantly share code, notes, and snippets.

@SegersIan
Created April 17, 2019 08:56
Show Gist options
  • Save SegersIan/6300a46206078e9e718059698808de01 to your computer and use it in GitHub Desktop.
Save SegersIan/6300a46206078e9e718059698808de01 to your computer and use it in GitHub Desktop.
async function thisThrows() {
throw new Error("Thrown from thisThrows()");
}
async function myFunctionThatCatches() {
try {
return thisThrows();
} catch (e) {
console.error(e);
} finally {
console.log('We do cleanup here');
}
return "Nothing found";
}
async function run() {
const myValue = await myFunctionThatCatches();
console.log(myValue);
}
run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment