diff --git a/doc/api/util.md b/doc/api/util.md index db56da1618e6f7..5ad1e5cdb56225 100644 --- a/doc/api/util.md +++ b/doc/api/util.md @@ -224,6 +224,25 @@ without any formatting. util.format('%% %s'); // '%% %s' ``` +## 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)