Skip to content

Commit 4b35dfb

Browse files
lpincaMylesBorins
authored andcommitted
doc: avoid mentioning 'uncaughtException'
Avoid suggesting using `'uncaughtException'` for emitted errors. PR-URL: #16905 Reviewed-By: Ben Noordhuis <[email protected]>
1 parent 78b82b0 commit 4b35dfb

File tree

1 file changed

+2
-15
lines changed

1 file changed

+2
-15
lines changed

doc/api/events.md

+2-15
Original file line numberDiff line numberDiff line change
@@ -142,20 +142,8 @@ myEmitter.emit('error', new Error('whoops!'));
142142
// Throws and crashes Node.js
143143
```
144144

145-
To guard against crashing the Node.js process, a listener can be registered
146-
on the [`process` object's `uncaughtException` event][] or the [`domain`][] module
147-
can be used. (Note, however, that the `domain` module has been deprecated.)
148-
149-
```js
150-
const myEmitter = new MyEmitter();
151-
152-
process.on('uncaughtException', (err) => {
153-
console.error('whoops! there was an error');
154-
});
155-
156-
myEmitter.emit('error', new Error('whoops!'));
157-
// Prints: whoops! there was an error
158-
```
145+
To guard against crashing the Node.js process the [`domain`][] module can be
146+
used. (Note, however, that the `domain` module has been deprecated.)
159147

160148
As a best practice, listeners should always be added for the `'error'` events.
161149

@@ -594,5 +582,4 @@ Returns a reference to the `EventEmitter`, so that calls can be chained.
594582
[`fs.ReadStream`]: fs.html#fs_class_fs_readstream
595583
[`net.Server`]: net.html#net_class_net_server
596584
[`process.on('warning')`]: process.html#process_event_warning
597-
[`process` object's `uncaughtException` event]: process.html#process_event_uncaughtexception
598585
[stream]: stream.html

0 commit comments

Comments
 (0)