events: Handle emit('error') before ctor

The previous commit did not handle the case when the event type
is 'error', since that is checked before reading the handler.
This commit is contained in:
isaacs committed 2013-03-02 15:11:23 -08:00
1 parent d345c1173a
commit 63edde0e01
2 files changed
+13 -3

No files matched your search

@@ -38,6 +38,16 @@ var myee = new MyEE(function() {
called = true;
});
util.inherits(ErrorEE, EventEmitter);
function ErrorEE() {
this.emit('error', new Error('blerg'));
}
assert.throws(function() {
new ErrorEE();
}, /blerg/);
process.on('exit', function() {
assert(called);
console.log('ok');