| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -142,20 +142,8 @@ myEmitter.emit('error', new Error('whoops!')); | |||
| 142 | 142 | // Throws and crashes Node.js | |
| 143 | 143 | ``` | |
| 144 | 144 | ||
| 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.) | ||
| 159 | 147 | ||
| 160 | 148 | As a best practice, listeners should always be added for the `'error'` events. | |
| 161 | 149 | ||
@@ -594,5 +582,4 @@ Returns a reference to the `EventEmitter`, so that calls can be chained. | |||
| 594 | 582 | [`fs.ReadStream`]: fs.html#fs_class_fs_readstream | |
| 595 | 583 | [`net.Server`]: net.html#net_class_net_server | |
| 596 | 584 | [`process.on('warning')`]: process.html#process_event_warning | |
| 597 | - [`process` object's `uncaughtException` event]: process.html#process_event_uncaughtexception | ||
| 598 | 585 | [stream]: stream.html | |
| Back | FazBrowse Home | New Git URL |
0 commit comments