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:
Gabriel Schulhof authored and Richard Lau committed 2024-03-25 19:26:00 +00:00
1 parent d0d5bd0e54
commit ecfb3f18b3
1 file changed
+4 -2
+4 -2
View File
@@ -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`,
);
});