Skip to content

Instantly share code, notes, and snippets.

@chuck0523
Last active September 4, 2019 08:18
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 chuck0523/437bba0dab1e283fb4b17bd2302506d1 to your computer and use it in GitHub Desktop.
Save chuck0523/437bba0dab1e283fb4b17bd2302506d1 to your computer and use it in GitHub Desktop.
const throwError = () => { throw new Error('foo') }
const delayFunc = async () => {
setTimeout(async () => {
try {
await throwError()
} catch(e) {
// This won't be captured by main function
throw e
}
}, 1000)
return
}
const main = async () => {
try {
await delayFunc()
} catch(e) {
// new Error('foo') won't reach here
console.error(`Error: ${e.stack}`)
}
}
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment