Skip to content

Instantly share code, notes, and snippets.

@edorivai
Created February 3, 2017 12:58
Show Gist options
  • Save edorivai/01308d3f0c52e21224360513125cf1dc to your computer and use it in GitHub Desktop.
Save edorivai/01308d3f0c52e21224360513125cf1dc to your computer and use it in GitHub Desktop.
async function() {
try {
const someValue = await getSomeValue();
doSomethingWith(someValue);
} catch (error) {
console.error(error);
}
}
async function() {
let someValue;
try {
someValue = await getSomeValue();
} catch (error) {
console.error(error);
return;
}
if (!someValue) return;
doSomethingWith(someValue);
}
async function() {
const someValue = await getSomeValue().catch(console.error.bind(console));
if (!someValue) return;
doSomethingWith(someValue);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment