mirror of
https://github.com/nodejs/node.git
synced 2026-11-25 23:01:06 -05:00
doc: fix uncaught exception example
PR-URL: https://github.com/nodejs/node/pull/51638 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Akhil Marsonya <akhil.marsonya27@gmail.com>
This commit is contained in:
1 parent
d0d5bd0e54
commit
ecfb3f18b3
1 file changed
+4
-2
+4
-2
@@ -360,12 +360,13 @@ exit with 0.
|
||||
|
||||
```mjs
|
||||
import process from 'node:process';
|
||||
import fs from 'node:fs';
|
||||
|
||||
process.on('uncaughtException', (err, origin) => {
|
||||
fs.writeSync(
|
||||
process.stderr.fd,
|
||||
`Caught exception: ${err}\n` +
|
||||
`Exception origin: ${origin}`,
|
||||
`Exception origin: ${origin}\n`,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -380,12 +381,13 @@ console.log('This will not run.');
|
||||
|
||||
```cjs
|
||||
const process = require('node:process');
|
||||
const fs = require('node:fs');
|
||||
|
||||
process.on('uncaughtException', (err, origin) => {
|
||||
fs.writeSync(
|
||||
process.stderr.fd,
|
||||
`Caught exception: ${err}\n` +
|
||||
`Exception origin: ${origin}`,
|
||||
`Exception origin: ${origin}\n`,
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user