diff --git a/doc/api/util.md b/doc/api/util.md index 864a866a7311b5..e59233e14a986e 100644 --- a/doc/api/util.md +++ b/doc/api/util.md @@ -257,6 +257,25 @@ intended as a debugging tool. Some input values can have a significant performance overhead that can block the event loop. Use this function with care and never in a hot code path. +## util.getSystemErrorName(err) + + +* `err` {number} +* Returns: {string} + +Returns the string name for a numeric error code that comes from a Node.js API. +The mapping between error codes and error names is platform-dependent. +See [Common System Errors][] for the names of common errors. + +```js +fs.access('file/that/does/not/exist', (err) => { + const name = util.getSystemErrorName(err.errno); + console.error(name); // ENOENT +}); +``` + ## util.inherits(constructor, superConstructor)