summaryrefslogtreecommitdiff
path: root/lib/events.js
diff options
context:
space:
mode:
authorWeijia Wang <381152119@qq.com>2017-12-13 20:48:43 +0800
committerWeijia Wang <381152119@qq.com>2017-12-24 14:09:29 +0800
commitd022cb1bdd20f10483cbe988a950548df2dfd48c (patch)
treee10d1a2c2d4957ef123a8aaadb9727bf674c00ae /lib/events.js
parent4d74b52979c60391bc369be69a34463eba61f383 (diff)
downloadandroid-node-v8-d022cb1bdd20f10483cbe988a950548df2dfd48c.tar.gz
android-node-v8-d022cb1bdd20f10483cbe988a950548df2dfd48c.tar.bz2
android-node-v8-d022cb1bdd20f10483cbe988a950548df2dfd48c.zip
lib: combine similar error codes
There two similar error codes in lib: "ERR_VALUE_OUT_OF_RANGE" and "ERR_OUT_OF_RANGE". This change is to reduce them into "ERR_VALUE_OUT_OF_RANGE" Fixes: https://github.com/nodejs/node/issues/17603 PR-URL: https://github.com/nodejs/node/pull/17648 Fixes: https://github.com/nodejs/node/issues/17603 Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Jon Moss <me@jonathanmoss.me> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'lib/events.js')
-rw-r--r--lib/events.js8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/events.js b/lib/events.js
index 28a8c4228b..9ad5ec376f 100644
--- a/lib/events.js
+++ b/lib/events.js
@@ -56,7 +56,10 @@ Object.defineProperty(EventEmitter, 'defaultMaxListeners', {
// greater and not a NaN).
if (typeof arg !== 'number' || arg < 0 || arg !== arg) {
const errors = lazyErrors();
- throw new errors.TypeError('ERR_OUT_OF_RANGE', 'defaultMaxListeners');
+ throw new errors.RangeError('ERR_OUT_OF_RANGE',
+ 'defaultMaxListeners',
+ 'a non-negative number',
+ arg);
}
defaultMaxListeners = arg;
}
@@ -78,7 +81,8 @@ EventEmitter.init = function() {
EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {
if (typeof n !== 'number' || n < 0 || isNaN(n)) {
const errors = lazyErrors();
- throw new errors.TypeError('ERR_OUT_OF_RANGE', 'n');
+ throw new errors.RangeError('ERR_OUT_OF_RANGE', 'n',
+ 'a non-negative number', n);
}
this._maxListeners = n;
return this;