Open ghost opened 11 years ago
http://nodejs.org/api/events.html#events_class_events_eventemitter
When an EventEmitter instance experiences an error, the typical action is to emit an 'error' event. Error events are treated as a special case in node. If there is no listener for it, then the default action is to print a stack trace and exit the program.
Si, it's better to emit an event error, instead of throw an exception.
But, there is already an error event if connection emit an error : https://github.com/arunoda/node-simple-xmpp/blob/master/lib/simple-xmpp.js#L176
Your issue should rather be opened on the node-xmpp repository: https://github.com/astro/node-xmpp/blob/master/lib/xmpp/connection.js#L63
Is this by design? I noticed that socket 'error' events simply call Connection.onEnd(), which quietly exits. I had a case where the socket couldn't connect to the host at all, and my process was quietly finishing looking like everything's fine.
As a work-around, I ended up listening to socket errors directly: