Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikermcneil/bd913197336390a4426dcf42afab9858 to your computer and use it in GitHub Desktop.
Save mikermcneil/bd913197336390a4426dcf42afab9858 to your computer and use it in GitHub Desktop.
...as long as you properly handle things at the top level. (or otherwise just let https://npmjs.com/package/parley do it for you)
async function hoHum() {
return 'ho hum';
}
async function hiHo() {
return 'hi ho!';
}
async function hoNo() {
throw new Error('ho... no!');
}
async function hiHoNo() {
return await hiHo() + await hoNo();
}
(async ()=>{
await hoHum();
await hiHo();
await hiHoNo();//•
await hoHum();
await hiHo();
})().catch((err) => {
console.error('Failed with an error:', err);
});
@mikermcneil
Copy link
Author

yields
image

@mikermcneil
Copy link
Author

(This gist is just an example to look at if you're worried about uncaught promise rejections and aren't sure if it's safe to use await in this way)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment