Skip to content

Instantly share code, notes, and snippets.

@coodoo
Last active February 21, 2022 06:54
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 coodoo/7774378057e7695cd527a8c2339239fc to your computer and use it in GitHub Desktop.
Save coodoo/7774378057e7695cd527a8c2339239fc to your computer and use it in GitHub Desktop.
async function foo() {
// throw new Error('bb')
return new Promise((res, rej) => {
setTimeout(_ => {
// throw new Error('bb')
rej('cc')
}, 1000)
})
}
async function main() {
try {
// foo()
// return foo()
// await foo()
return await foo()
} catch (e) {
console.log('catch', e)
} finally {
console.log('finally')
}
}
main().then(r => console.log('main'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment