GeezerVison is showing github.com — doc: clarify repl exception conditions · nodejs/node@d340dca
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: doc/api/repl.md +11-20Lines changed: 11 additions & 20 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -163,30 +163,21 @@ This use of the [`domain`][] module in the REPL has these side effects: |
163 | 163 |
|
164 | 164 | * Uncaught exceptions only emit the [`'uncaughtException'`][] event in the |
165 | 165 | standalone REPL. Adding a listener for this event in a REPL within |
166 | | - another Node.js program throws [`ERR_INVALID_REPL_INPUT`][]. |
167 | | -* Trying to use [`process.setUncaughtExceptionCaptureCallback()`][] throws |
168 | | - an [`ERR_DOMAIN_CANNOT_SET_UNCAUGHT_EXCEPTION_CAPTURE`][] error. |
169 | | - |
170 | | -As standalone program: |
171 | | - |
172 | | -```js |
173 | | -process.on('uncaughtException', () => console.log('Uncaught')); |
| 166 | + another Node.js program results in [`ERR_INVALID_REPL_INPUT`][]. |
174 | 167 |
|
175 | | -throw new Error('foobar'); |
176 | | -// Uncaught |
177 | | -``` |
| 168 | + ```js |
| 169 | + const r = repl.start(); |
178 | 170 |
|
179 | | -When used in another application: |
| 171 | + r.write('process.on("uncaughtException", () => console.log("Foobar"));\n'); |
| 172 | + // Output stream includes: |
| 173 | + // TypeError [ERR_INVALID_REPL_INPUT]: Listeners for `uncaughtException` |
| 174 | + // cannot be used in the REPL |
180 | 175 |
|
181 | | -```js |
182 | | -process.on('uncaughtException', () => console.log('Uncaught')); |
183 | | -// TypeError [ERR_INVALID_REPL_INPUT]: Listeners for `uncaughtException` |
184 | | -// cannot be used in the REPL |
| 176 | + r.close(); |
| 177 | + ``` |
185 | 178 |
|
186 | | -throw new Error('foobar'); |
187 | | -// Thrown: |
188 | | -// Error: foobar |
189 | | -``` |
| 179 | +* Trying to use [`process.setUncaughtExceptionCaptureCallback()`][] throws |
| 180 | + an [`ERR_DOMAIN_CANNOT_SET_UNCAUGHT_EXCEPTION_CAPTURE`][] error. |
190 | 181 |
|
191 | 182 | #### Assignment of the `_` (underscore) variable |
192 | 183 | <!-- YAML |
|