Skip to content

Commit 960e326

Browse files
committed
don't throw errors in error first callbacks,read Error-first callbacks under Errors
1 parent 040f6df commit 960e326

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

doc/api/fs.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3212,7 +3212,10 @@ import { mkdir } from 'node:fs';
32123212
32133213
// Create ./tmp/a/apple, regardless of whether ./tmp and ./tmp/a exist.
32143214
mkdir('./tmp/a/apple', { recursive: true }, (err) => {
3215-
if (err) throw err;
3215+
if (err) {
3216+
console.log(err)
3217+
return
3218+
}
32163219
});
32173220
```
32183221
@@ -3315,7 +3318,10 @@ mkdtemp(tmpDir, (err, directory) => {
33153318
// This method is *CORRECT*:
33163319
import { sep } from 'node:path';
33173320
mkdtemp(`${tmpDir}${sep}`, (err, directory) => {
3318-
if (err) throw err;
3321+
if (err) {
3322+
console.log(err)
3323+
return
3324+
}
33193325
console.log(directory);
33203326
// Will print something similar to `/tmp/abc123`.
33213327
// A new temporary directory is created within
@@ -3659,7 +3665,10 @@ Asynchronously reads the entire contents of a file.
36593665
import { readFile } from 'node:fs';
36603666

36613667
readFile('/etc/passwd', (err, data) => {
3662-
if (err) throw err;
3668+
if (err) {
3669+
console.log(err)
3670+
return
3671+
}
36633672
console.log(data);
36643673
});
36653674
```

0 commit comments

Comments
 (0)