Skip to content

Instantly share code, notes, and snippets.

@yowcow
Created April 8, 2024 09:10
Show Gist options
  • Save yowcow/3592317e7dd1313ddb799281062b5538 to your computer and use it in GitHub Desktop.
Save yowcow/3592317e7dd1313ddb799281062b5538 to your computer and use it in GitHub Desktop.
const main = async () => {
try {
const ret = await new Promise(() => {
setTimeout(() => {
throw new Error('error in setTimeout');
}, 1);
});
console.log(`promise succeeded: ${ret}`);
} catch (err: unknown) {
console.error(`promise failed: ${err}`);
}
};
main()
.then(() => console.log('main finished'))
.catch((err) => console.error(`main failed: ${err}`));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment