UNPKG

presidium-websocket

Version:

Presidium WebSocket client and server for Node.js

21 lines (19 loc) 538 B
/** * @name unhandledErrorListener * * @docs * Exits the process on error if this is the only listener for the error event. * * ```coffeescript [specscript] * unhandledErrorListener(error Error) -> () * ``` */ function unhandledErrorListener(error) { const errorListenerCount = this.listenerCount('error') const errorListeners = this.listeners('error') if (errorListenerCount == 1 && errorListeners[0] == unhandledErrorListener) { console.error(error) process.exit(1) } } module.exports = unhandledErrorListener