Skip to content

Instantly share code, notes, and snippets.

@gregpalaci
Created January 15, 2024 19:23
Show Gist options
  • Save gregpalaci/dd917a3bce99f9468e42ad4db09511d3 to your computer and use it in GitHub Desktop.
Save gregpalaci/dd917a3bce99f9468e42ad4db09511d3 to your computer and use it in GitHub Desktop.
await without catch
const doAwait = async (promise) => {
try {
const data = await promise;
return [undefined, data];
} catch (error) {
return [error, undefined];
}
};
const [error, result] = await doAwait(myPromise);
if (error) {
throw error;
}
doStuff(result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment