Skip to content

Commit

Permalink
don't throw errors in error first callbacks,read Error-first callback…
Browse files Browse the repository at this point in the history
…s under Errors
  • Loading branch information
Stevepurpose committed Jun 6, 2023
1 parent 040f6df commit 960e326
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions doc/api/fs.md
Original file line number Diff line number Diff line change
Expand Up @@ -3212,7 +3212,10 @@ import { mkdir } from 'node:fs';
// Create ./tmp/a/apple, regardless of whether ./tmp and ./tmp/a exist.
mkdir('./tmp/a/apple', { recursive: true }, (err) => {
if (err) throw err;
if (err) {
console.log(err)
return
}
});
```
Expand Down Expand Up @@ -3315,7 +3318,10 @@ mkdtemp(tmpDir, (err, directory) => {
// This method is *CORRECT*:
import { sep } from 'node:path';
mkdtemp(`${tmpDir}${sep}`, (err, directory) => {
if (err) throw err;
if (err) {
console.log(err)
return
}
console.log(directory);
// Will print something similar to `/tmp/abc123`.
// A new temporary directory is created within
Expand Down Expand Up @@ -3659,7 +3665,10 @@ Asynchronously reads the entire contents of a file.
import { readFile } from 'node:fs';

readFile('/etc/passwd', (err, data) => {
if (err) throw err;
if (err) {
console.log(err)
return
}
console.log(data);
});
```
Expand Down

0 comments on commit 960e326

Please sign in to comment.