util.getSystemErrorMap()
- 返回:<Map>
返回一个包含 Node.js API 提供的所有系统错误代码的 Map。错误代码与错误名称之间的映射依赖于平台。有关常见错误的名称,请参见 常见系统错误。
【Returns a Map of all system error codes available from the Node.js API. The mapping between error codes and error names is platform-dependent. See Common System Errors for the names of common errors.】
fs.access('file/that/does/not/exist', (err) => {
const errorMap = util.getSystemErrorMap();
const name = errorMap.get(err.errno);
console.error(name); // ENOENT
});