Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

EventEmitter throws when emitting 'error' #3103

Closed
Munter opened this issue Sep 28, 2015 · 4 comments
Closed

EventEmitter throws when emitting 'error' #3103

Munter opened this issue Sep 28, 2015 · 4 comments

Comments

@Munter
Copy link

Munter commented Sep 28, 2015

This code

var events = require('events');
var emitter = new events.EventEmitter();
emitter.emit('error');

throws:

events.js:74
        throw TypeError('Uncaught, unspecified "error" event.');
              ^
TypeError: Uncaught, unspecified "error" event.
    at TypeError (<anonymous>)
    at EventEmitter.emit (events.js:74:15)
    at Object.<anonymous> (/Users/munter/git/fusile/waat.js:7:6)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:935:3

If I have at least one emitter.on('error', ...) listener it doesn't throw

@Munter
Copy link
Author

Munter commented Sep 28, 2015

Ah, now I found it in the docs. Closing :(

@Munter Munter closed this as completed Sep 28, 2015
@justinmchase
Copy link

@Munter Where is this in the docs?

I am looking here:
https://nodejs.org/api/events.html#events_emitter_emit_event_arg1_arg2

And it says it should return a boolean but nothing about throwing an error. Has this documentation regressed?

@targos
Copy link
Member

targos commented Dec 14, 2015

@justinmchase it is in this section: https://nodejs.org/api/events.html#events_class_events_eventemitter

@justinmchase
Copy link

@targos Thanks!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants