Skip to content
Prev Previous commit
Next Next commit
add API doc
  • Loading branch information
eladkishon committed Apr 9, 2021
commit 87fb10e82c1f66a343817a519a23364f9cacadb2
16 changes: 15 additions & 1 deletion doc/api/util.md
Original file line number Diff line number Diff line change
Expand Up @@ -369,9 +369,23 @@ 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.

## `util.getSystemErrorMap()`
<!-- YAML
added: v9.7.0
Comment thread
EladKeyshawn marked this conversation as resolved.
Outdated
-->

* Returns: {Map}

Returns a Map of all system error codes available from Node.js API.
Comment thread
EladKeyshawn marked this conversation as resolved.
Outdated
The mapping between error codes and error names is platform-dependent.
See [Common System Errors][] for the names of common errors.



Comment thread
EladKeyshawn marked this conversation as resolved.
Outdated
```js
fs.access('file/that/does/not/exist', (err) => {
const name = util.getSystemErrorName(err.errno);
const errorMap = util.getSystemErrorMap();
const name = errorMap.get(err.errno);
Comment thread
EladKeyshawn marked this conversation as resolved.
console.error(name); // ENOENT
});
```
Expand Down