summaryrefslogtreecommitdiff
path: root/lib/util.js
diff options
context:
space:
mode:
authorJoyee Cheung <joyeec9h3@gmail.com>2018-02-03 17:30:48 +0800
committerJoyee Cheung <joyeec9h3@gmail.com>2018-02-07 18:42:27 +0800
commit12ae33476a69a3b13477ffd60a7497088e769870 (patch)
treed8f607a94d8e0617b82c408b97307328c4202c0e /lib/util.js
parentbff5d5b8f0c462880ef63a396d8912d5188bbd31 (diff)
downloadandroid-node-v8-12ae33476a69a3b13477ffd60a7497088e769870.tar.gz
android-node-v8-12ae33476a69a3b13477ffd60a7497088e769870.tar.bz2
android-node-v8-12ae33476a69a3b13477ffd60a7497088e769870.zip
util: skip type checks in internal getSystemErrorName
PR-URL: https://github.com/nodejs/node/pull/18546 Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'lib/util.js')
-rw-r--r--lib/util.js13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/util.js b/lib/util.js
index 4525792b2e..14c99bd454 100644
--- a/lib/util.js
+++ b/lib/util.js
@@ -55,7 +55,7 @@ const {
const {
customInspectSymbol,
deprecate,
- getSystemErrorName,
+ getSystemErrorName: internalErrorName,
getIdentificationOf,
isError,
promisify,
@@ -1139,6 +1139,17 @@ function callbackify(original) {
return callbackified;
}
+function getSystemErrorName(err) {
+ if (typeof err !== 'number') {
+ throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'err', 'number', err);
+ }
+ if (err >= 0 || !Number.isSafeInteger(err)) {
+ throw new errors.RangeError('ERR_OUT_OF_RANGE', 'err',
+ 'a negative integer', err);
+ }
+ return internalErrorName(err);
+}
+
// Keep the `exports =` so that various functions can still be monkeypatched
module.exports = exports = {
_errnoException,