Created
April 8, 2024 09:10
-
-
Save yowcow/3592317e7dd1313ddb799281062b5538 to your computer and use it in GitHub Desktop.
This file contains 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
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