Skip to content

Commit

Permalink
util: skip type checks in internal getSystemErrorName
Browse files Browse the repository at this point in the history
PR-URL: nodejs#18546
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
joyeecheung committed Feb 22, 2018
1 parent a2a2f06 commit 8006e0b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
5 changes: 0 additions & 5 deletions lib/internal/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;
}
Expand Down
10 changes: 9 additions & 1 deletion lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const {
customInspectSymbol,
deprecate,
getConstructorOf,
getSystemErrorName,
getSystemErrorName: internalErrorName,
isError,
promisify,
join,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 8006e0b

Please sign in to comment.