diff --git a/doc/api/errors.md b/doc/api/errors.md index c0952792727e53..6e4df3f6035f07 100644 --- a/doc/api/errors.md +++ b/doc/api/errors.md @@ -409,12 +409,15 @@ The location information will be one of: its dependencies. The string representing the stack trace is lazily generated when the -`error.stack` property is **accessed**. +`error.stack` property is **accessed**. The number of frames captured by the stack trace is bounded by the smaller of `Error.stackTraceLimit` or the number of available frames on the current event loop tick. +However `error.stack` does not work on Microsoft,works only on Firefox . + + ## Class: `AssertionError` * Extends: {errors.Error} diff --git a/doc/api/fs.md b/doc/api/fs.md index cc8bce4b0431fa..f38da4ea72e946 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -3198,20 +3198,24 @@ Asynchronously creates a directory. The callback is given a possible exception and, if `recursive` is `true`, the first directory path created, `(err[, path])`. `path` can still be `undefined` when `recursive` is `true`, if no directory was -created. +created (for instance, if it was previously created). The optional `options` argument can be an integer specifying `mode` (permission and sticky bits), or an object with a `mode` property and a `recursive` property indicating whether parent directories should be created. Calling `fs.mkdir()` when `path` is a directory that exists results in an error only -when `recursive` is false. +when `recursive` is false. If `recursive` is false and the directory exists, +an `EEXIST` error occurs. ```mjs import { mkdir } from 'node:fs'; -// Creates /tmp/a/apple, regardless of whether `/tmp` and /tmp/a exist. -mkdir('/tmp/a/apple', { recursive: true }, (err) => { - if (err) throw err; +// Create ./tmp/a/apple. +mkdir('./tmp/a/apple', { recursive: true }, (err) => { + if (err) { + console.log(err) + return + } }); ``` @@ -3314,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 @@ -3658,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); }); ```