Skip to content

Commit

Permalink
doc: fix uncaught exception example
Browse files Browse the repository at this point in the history
PR-URL: #51638
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Akhil Marsonya <akhil.marsonya27@gmail.com>
  • Loading branch information
gabrielschulhof authored and richardlau committed Mar 25, 2024
1 parent d0d5bd0 commit ecfb3f1
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions doc/api/process.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
);
});

Expand All @@ -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`,
);
});

Expand Down

0 comments on commit ecfb3f1

Please sign in to comment.