diff --git a/lib/internal/util.js b/lib/internal/util.js index 51505f6845f3c7..fd481450bc246d 100644 --- a/lib/internal/util.js +++ b/lib/internal/util.js @@ -208,11 +208,6 @@ function getConstructorOf(obj) { } function getSystemErrorName(err) { - if (typeof err !== 'number' || err >= 0 || !Number.isSafeInteger(err)) { - throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'err', - 'negative number'); - } - const entry = errmap.get(err); return entry ? entry[0] : `Unknown system error ${err}`; } diff --git a/lib/util.js b/lib/util.js index ac2c998ccab627..539608c4164893 100644 --- a/lib/util.js +++ b/lib/util.js @@ -54,7 +54,7 @@ const { customInspectSymbol, deprecate, getConstructorOf, - getSystemErrorName, + getSystemErrorName: internalErrorName, isError, promisify, join, @@ -1071,6 +1071,14 @@ function callbackify(original) { return callbackified; } +function getSystemErrorName(err) { + if (typeof err !== 'number' || err >= 0 || !Number.isSafeInteger(err)) { + throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'err', + 'negative number'); + } + return internalErrorName(err); +} + // Keep the `exports =` so that various functions can still be monkeypatched module.exports = exports = { _errnoException,