Last active
September 4, 2019 08:18
-
-
Save chuck0523/437bba0dab1e283fb4b17bd2302506d1 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 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