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.