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: #19191
PR-URL: #18546
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
joyeecheung authored and MylesBorins committed Jun 14, 2018
1 parent ff693d2 commit ae81a04
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 @@ -202,11 +202,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 @@ -50,7 +50,7 @@ const {
customInspectSymbol,
deprecate,
getConstructorOf,
getSystemErrorName,
getSystemErrorName: internalErrorName,
isError,
promisify,
join
Expand Down Expand Up @@ -1065,6 +1065,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 ae81a04

Please sign in to comment.