diff options
author | Rich Trott <rtrott@gmail.com> | 2021-01-30 16:39:16 +0300 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2021-02-01 16:42:27 +0300 |
commit | e30e035dcdbe3a4d0af62211496be6ca100a7204 (patch) | |
tree | afba6523f321818bbf985eeb2782e39bd8f7ed50 /doc/api/repl.md | |
parent | c746c403ab4747f6f7e258367b401d03394ba77f (diff) |
doc: clarify repl exception conditions
The sample code demonstrating ERR_INVALID_REPL_INPUT is confusing, I
think. This simplifies and clarifies it a bit, I hope.
PR-URL: https://github.com/nodejs/node/pull/37142
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Zijian Liu <lxxyxzj@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Diffstat (limited to 'doc/api/repl.md')
-rw-r--r-- | doc/api/repl.md | 31 |
1 files changed, 11 insertions, 20 deletions
diff --git a/doc/api/repl.md b/doc/api/repl.md index 10536aeb0e1..bf5ee1efef3 100644 --- a/doc/api/repl.md +++ b/doc/api/repl.md @@ -163,30 +163,21 @@ This use of the [`domain`][] module in the REPL has these side effects: * Uncaught exceptions only emit the [`'uncaughtException'`][] event in the standalone REPL. Adding a listener for this event in a REPL within - another Node.js program throws [`ERR_INVALID_REPL_INPUT`][]. -* Trying to use [`process.setUncaughtExceptionCaptureCallback()`][] throws - an [`ERR_DOMAIN_CANNOT_SET_UNCAUGHT_EXCEPTION_CAPTURE`][] error. - -As standalone program: - -```js -process.on('uncaughtException', () => console.log('Uncaught')); + another Node.js program results in [`ERR_INVALID_REPL_INPUT`][]. -throw new Error('foobar'); -// Uncaught -``` + ```js + const r = repl.start(); -When used in another application: + r.write('process.on("uncaughtException", () => console.log("Foobar"));\n'); + // Output stream includes: + // TypeError [ERR_INVALID_REPL_INPUT]: Listeners for `uncaughtException` + // cannot be used in the REPL -```js -process.on('uncaughtException', () => console.log('Uncaught')); -// TypeError [ERR_INVALID_REPL_INPUT]: Listeners for `uncaughtException` -// cannot be used in the REPL + r.close(); + ``` -throw new Error('foobar'); -// Thrown: -// Error: foobar -``` +* Trying to use [`process.setUncaughtExceptionCaptureCallback()`][] throws + an [`ERR_DOMAIN_CANNOT_SET_UNCAUGHT_EXCEPTION_CAPTURE`][] error. #### Assignment of the `_` (underscore) variable <!-- YAML |