diff options
author | Luigi Pinca <luigipinca@gmail.com> | 2017-11-09 17:58:42 +0100 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2017-11-18 21:07:06 +0100 |
commit | 9531fcbb2e447c6a5ef0366c5446e10f90073cb5 (patch) | |
tree | 141ac1355a408c906107697e3ed90e5e3fb53e1a /doc | |
parent | fe932a1204a25de351d52b762b983ffb9eae6ebd (diff) | |
download | android-node-v8-9531fcbb2e447c6a5ef0366c5446e10f90073cb5.tar.gz android-node-v8-9531fcbb2e447c6a5ef0366c5446e10f90073cb5.tar.bz2 android-node-v8-9531fcbb2e447c6a5ef0366c5446e10f90073cb5.zip |
doc: avoid mentioning 'uncaughtException'
Avoid suggesting using `'uncaughtException'` for emitted errors.
PR-URL: https://github.com/nodejs/node/pull/16905
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'doc')
-rw-r--r-- | doc/api/events.md | 17 |
1 files changed, 2 insertions, 15 deletions
diff --git a/doc/api/events.md b/doc/api/events.md index b08dc23d32..443137f170 100644 --- a/doc/api/events.md +++ b/doc/api/events.md @@ -142,20 +142,8 @@ myEmitter.emit('error', new Error('whoops!')); // Throws and crashes Node.js ``` -To guard against crashing the Node.js process, a listener can be registered -on the [`process` object's `uncaughtException` event][] or the [`domain`][] module -can be used. (Note, however, that the `domain` module has been deprecated.) - -```js -const myEmitter = new MyEmitter(); - -process.on('uncaughtException', (err) => { - console.error('whoops! there was an error'); -}); - -myEmitter.emit('error', new Error('whoops!')); -// Prints: whoops! there was an error -``` +To guard against crashing the Node.js process the [`domain`][] module can be +used. (Note, however, that the `domain` module has been deprecated.) As a best practice, listeners should always be added for the `'error'` events. @@ -594,5 +582,4 @@ Returns a reference to the `EventEmitter`, so that calls can be chained. [`fs.ReadStream`]: fs.html#fs_class_fs_readstream [`net.Server`]: net.html#net_class_net_server [`process.on('warning')`]: process.html#process_event_warning -[`process` object's `uncaughtException` event]: process.html#process_event_uncaughtexception [stream]: stream.html |