-
-
Save coodoo/7774378057e7695cd527a8c2339239fc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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