📌  相关文章
📜  节点事件发射器发出错误 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:26.497000             🧑  作者: Mango

代码示例1
// If an EventEmitter does not have at least one listener 
// registered for the 'error' event, and an 'error' event 
// is emitted, the error is thrown, a stack trace is printed, 
// and the Node.js process exits.

const myEmitter = new MyEmitter();
myEmitter.emit('error', new Error('whoops!'));
// Throws and crashes Node.js