Created
June 11, 2020 20:11
-
-
Save jasnell/73e66d445acb5e240d8e7a0028b8b9e8 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
const EventEmitter = require('events') | |
const { promisify } = require('util') | |
const foo = new EventEmitter() | |
const sleep = promisify(setTimeout) | |
foo.on('something', async () => { | |
await sleep(100) | |
try { | |
functionThatDoesNotExist() | |
} catch (err) { | |
foo.emit('error', err) | |
} | |
}) | |
foo.on('error', (err) => { | |
throw new Error('boom') | |
}) | |
foo.emit('something') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment