Skip to content

Commit

Permalink
util: skip type checks in internal getSystemErrorName
Browse files Browse the repository at this point in the history
Backport-PR-URL: #18916
PR-URL: #18546
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
joyeecheung authored and MylesBorins committed Feb 26, 2018
1 parent 9cb3f10 commit f1f180d
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 f1f180d

Please sign in to comment.