From ed0c109950bdd34ccfd1d3aaaa63e38b50d2097e Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Wed, 12 May 2010 10:42:14 -0700 Subject: [PATCH] Add note about 'error' event to docs --- doc/api.markdown | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/doc/api.markdown b/doc/api.markdown index 0365bf67176..27c7ed6e2b4 100644 --- a/doc/api.markdown +++ b/doc/api.markdown @@ -223,12 +223,23 @@ is emitted. These functions are called _listeners_. All EventEmitters emit the event `'newListener'` when new listeners are added. +When an EventEmitter experiences an error, the typical action is to emit an +`'error'` event. Error events are special--if there is no handler for them +they will print a stack trace and exit the program. + ### Event: 'newListener' `function (event, listener) { }` This event is made any time someone adds a new listener. +### Event: 'error' + +`function (exception) { }` + +If an error was encountered, then this event is emitted. This event is +special - when there are no listeners to receive the error Node will +terminate execution and display the exception's stack trace. ### emitter.addListener(event, listener)