summaryrefslogtreecommitdiff
path: root/js/src
diff options
context:
space:
mode:
authorJose <jose@zeroc.com>2018-10-26 14:30:30 +0200
committerJose <jose@zeroc.com>2018-10-26 14:30:30 +0200
commit067168b442ff0d449547f9e0731939354837ce46 (patch)
treeef46cc3a288d0c578d2542ed91b07649304aa5ce /js/src
parentOverqualification in C# generated code (diff)
downloadice-067168b442ff0d449547f9e0731939354837ce46.tar.bz2
ice-067168b442ff0d449547f9e0731939354837ce46.tar.xz
ice-067168b442ff0d449547f9e0731939354837ce46.zip
Use RangeError in JavsScript to report invalid arguments
Close #247
Diffstat (limited to 'js/src')
-rw-r--r--js/src/Ice/Buffer.js40
-rw-r--r--js/src/Ice/ConnectionI.js2
-rw-r--r--js/src/Ice/HashMap.js4
-rw-r--r--js/src/Ice/ObjectPrx.js10
-rw-r--r--js/src/Ice/OutgoingAsync.js2
-rw-r--r--js/src/Ice/StringUtil.js18
6 files changed, 38 insertions, 38 deletions
diff --git a/js/src/Ice/Buffer.js b/js/src/Ice/Buffer.js
index 464742dd00d..6df3d4a0110 100644
--- a/js/src/Ice/Buffer.js
+++ b/js/src/Ice/Buffer.js
@@ -127,7 +127,7 @@ class Buffer
{
if(this._position === this._limit)
{
- throw new Error(bufferOverflowExceptionMsg);
+ throw new RangeError(bufferOverflowExceptionMsg);
}
this.v.setUint8(this._position, v);
this._position++;
@@ -137,7 +137,7 @@ class Buffer
{
if(i >= this._limit)
{
- throw new Error(indexOutOfBoundsExceptionMsg);
+ throw new RangeError(indexOutOfBoundsExceptionMsg);
}
this.v.setUint8(i, v);
}
@@ -153,7 +153,7 @@ class Buffer
{
if(this._position + v.length > this._limit)
{
- throw new Error(bufferOverflowExceptionMsg);
+ throw new RangeError(bufferOverflowExceptionMsg);
}
new Uint8Array(this.b, 0, this.b.byteLength).set(v, this._position);
this._position += v.byteLength;
@@ -164,7 +164,7 @@ class Buffer
{
if(this._position + 2 > this._limit)
{
- throw new Error(bufferOverflowExceptionMsg);
+ throw new RangeError(bufferOverflowExceptionMsg);
}
this.v.setInt16(this._position, v, true);
this._position += 2;
@@ -174,7 +174,7 @@ class Buffer
{
if(this._position + 4 > this._limit)
{
- throw new Error(bufferOverflowExceptionMsg);
+ throw new RangeError(bufferOverflowExceptionMsg);
}
this.v.setInt32(this._position, v, true);
this._position += 4;
@@ -184,7 +184,7 @@ class Buffer
{
if(i + 4 > this._limit || i < 0)
{
- throw new Error(indexOutOfBoundsExceptionMsg);
+ throw new RangeError(indexOutOfBoundsExceptionMsg);
}
this.v.setInt32(i, v, true);
}
@@ -193,7 +193,7 @@ class Buffer
{
if(this._position + 4 > this._limit)
{
- throw new Error(bufferOverflowExceptionMsg);
+ throw new RangeError(bufferOverflowExceptionMsg);
}
this.v.setFloat32(this._position, v, true);
this._position += 4;
@@ -203,7 +203,7 @@ class Buffer
{
if(this._position + 8 > this._limit)
{
- throw new Error(bufferOverflowExceptionMsg);
+ throw new RangeError(bufferOverflowExceptionMsg);
}
this.v.setFloat64(this._position, v, true);
this._position += 8;
@@ -213,7 +213,7 @@ class Buffer
{
if(this._position + 8 > this._limit)
{
- throw new Error(bufferOverflowExceptionMsg);
+ throw new RangeError(bufferOverflowExceptionMsg);
}
this.v.setInt32(this._position, v.low, true);
this._position += 4;
@@ -237,7 +237,7 @@ class Buffer
{
if(this._position + sz > this._limit)
{
- throw new Error(bufferOverflowExceptionMsg);
+ throw new RangeError(bufferOverflowExceptionMsg);
}
for(let i = 0; i < sz; ++i)
{
@@ -250,7 +250,7 @@ class Buffer
{
if(this._position >= this._limit)
{
- throw new Error(bufferUnderflowExceptionMsg);
+ throw new RangeError(bufferUnderflowExceptionMsg);
}
const v = this.v.getUint8(this._position);
this._position++;
@@ -261,7 +261,7 @@ class Buffer
{
if(i < 0 || i >= this._limit)
{
- throw new Error(indexOutOfBoundsExceptionMsg);
+ throw new RangeError(indexOutOfBoundsExceptionMsg);
}
return this.v.getUint8(i);
}
@@ -270,7 +270,7 @@ class Buffer
{
if(this._position + length > this._limit)
{
- throw new Error(bufferUnderflowExceptionMsg);
+ throw new RangeError(bufferUnderflowExceptionMsg);
}
const buffer = this.b.slice(this._position, this._position + length);
this._position += length;
@@ -281,7 +281,7 @@ class Buffer
{
if(position + length > this._limit)
{
- throw new Error(bufferUnderflowExceptionMsg);
+ throw new RangeError(bufferUnderflowExceptionMsg);
}
return new Uint8Array(
this.b.slice(position, position + length === undefined ?
@@ -292,7 +292,7 @@ class Buffer
{
if(this._limit - this._position < 2)
{
- throw new Error(bufferUnderflowExceptionMsg);
+ throw new RangeError(bufferUnderflowExceptionMsg);
}
const v = this.v.getInt16(this._position, true);
this._position += 2;
@@ -303,7 +303,7 @@ class Buffer
{
if(this._limit - this._position < 4)
{
- throw new Error(bufferUnderflowExceptionMsg);
+ throw new RangeError(bufferUnderflowExceptionMsg);
}
const v = this.v.getInt32(this._position, true);
this._position += 4;
@@ -314,7 +314,7 @@ class Buffer
{
if(this._limit - this._position < 4)
{
- throw new Error(bufferUnderflowExceptionMsg);
+ throw new RangeError(bufferUnderflowExceptionMsg);
}
const v = this.v.getFloat32(this._position, true);
this._position += 4;
@@ -325,7 +325,7 @@ class Buffer
{
if(this._limit - this._position < 8)
{
- throw new Error(bufferUnderflowExceptionMsg);
+ throw new RangeError(bufferUnderflowExceptionMsg);
}
const v = this.v.getFloat64(this._position, true);
this._position += 8;
@@ -336,7 +336,7 @@ class Buffer
{
if(this._limit - this._position < 8)
{
- throw new Error(bufferUnderflowExceptionMsg);
+ throw new RangeError(bufferUnderflowExceptionMsg);
}
const low = this.v.getUint32(this._position, true);
this._position += 4;
@@ -350,7 +350,7 @@ class Buffer
{
if(this._position + length > this._limit)
{
- throw new Error(bufferUnderflowExceptionMsg);
+ throw new RangeError(bufferUnderflowExceptionMsg);
}
const data = new DataView(this.b, this._position, length);
diff --git a/js/src/Ice/ConnectionI.js b/js/src/Ice/ConnectionI.js
index 9c7ac5df77f..518ae9a0c72 100644
--- a/js/src/Ice/ConnectionI.js
+++ b/js/src/Ice/ConnectionI.js
@@ -510,7 +510,7 @@ class ConnectionI
{
if(timeout !== undefined && timeout < 0)
{
- throw new Error("invalid negative ACM timeout value");
+ throw new RangeError("invalid negative ACM timeout value");
}
if(this._monitor === null || this._state >= StateClosed)
{
diff --git a/js/src/Ice/HashMap.js b/js/src/Ice/HashMap.js
index 71dda4b2574..3c712c335cf 100644
--- a/js/src/Ice/HashMap.js
+++ b/js/src/Ice/HashMap.js
@@ -397,7 +397,7 @@ class HashMap
if(v === undefined)
{
- throw new Error("cannot compute hash for undefined value");
+ throw new RangeError("cannot compute hash for undefined value");
}
if(typeof v.hashCode === "function")
@@ -428,7 +428,7 @@ class HashMap
return {key: v, hash: v ? 1 : 0};
}
- throw new Error("cannot compute hash for value of type " + type);
+ throw new RangeError("cannot compute hash for value of type " + type);
}
keysEqual(k1, k2)
diff --git a/js/src/Ice/ObjectPrx.js b/js/src/Ice/ObjectPrx.js
index 3e83bcba57f..4d6143b4c97 100644
--- a/js/src/Ice/ObjectPrx.js
+++ b/js/src/Ice/ObjectPrx.js
@@ -168,7 +168,7 @@ class ObjectPrx
{
if(newTimeout < -1)
{
- throw new Error("invalid value passed to ice_locatorCacheTimeout: " + newTimeout);
+ throw new RangeError("invalid value passed to ice_locatorCacheTimeout: " + newTimeout);
}
if(newTimeout === this._reference.getLocatorCacheTimeout())
{
@@ -189,7 +189,7 @@ class ObjectPrx
{
if(newTimeout < 1 && newTimeout !== -1)
{
- throw new Error("invalid value passed to ice_invocationTimeout: " + newTimeout);
+ throw new RangeError("invalid value passed to ice_invocationTimeout: " + newTimeout);
}
if(newTimeout === this._reference.getInvocationTimeout())
{
@@ -413,7 +413,7 @@ class ObjectPrx
{
if(t < 1 && t !== -1)
{
- throw new Error("invalid value passed to ice_timeout: " + t);
+ throw new RangeError("invalid value passed to ice_timeout: " + t);
}
const ref = this._reference.changeTimeout(t);
if(ref.equals(this._reference))
@@ -435,11 +435,11 @@ class ObjectPrx
{
if(connection === null)
{
- throw new Error("invalid null connection passed to ice_fixed");
+ throw new RangeError("invalid null connection passed to ice_fixed");
}
if(!(connection instanceof Ice.ConnectionI))
{
- throw new Error("invalid connection passed to ice_fixed");
+ throw new RangeError("invalid connection passed to ice_fixed");
}
const ref = this._reference.changeConnection(connection);
if(ref.equals(this._reference))
diff --git a/js/src/Ice/OutgoingAsync.js b/js/src/Ice/OutgoingAsync.js
index c8fe3a4d6e3..43cd3328886 100644
--- a/js/src/Ice/OutgoingAsync.js
+++ b/js/src/Ice/OutgoingAsync.js
@@ -243,7 +243,7 @@ class OutgoingAsync extends ProxyOutgoingAsyncBase
{
if(ctx !== null && !(ctx instanceof Map))
{
- throw new Error("illegal context value, expecting null or Map");
+ throw new RangeError("illegal context value, expecting null or Map");
}
//
diff --git a/js/src/Ice/StringUtil.js b/js/src/Ice/StringUtil.js
index 3bef1d37639..cc7bc6d54e3 100644
--- a/js/src/Ice/StringUtil.js
+++ b/js/src/Ice/StringUtil.js
@@ -62,7 +62,7 @@ Ice.StringUtil = class
{
if(special.charCodeAt(i) < 32 || special.charCodeAt(i) > 126)
{
- throw new Error("special characters must be in ASCII range 32-126");
+ throw new RangeError("special characters must be in ASCII range 32-126");
}
}
}
@@ -93,7 +93,7 @@ Ice.StringUtil = class
Debug.assert(toStringMode === Ice.ToStringMode.ASCII && c >= 0xD800 && c <= 0xDFFF);
if(i + 1 === s.length)
{
- throw new Error("High surrogate without low surrogate");
+ throw new RangeError("High surrogate without low surrogate");
}
else
{
@@ -134,7 +134,7 @@ Ice.StringUtil = class
{
if(special.charCodeAt(i) < 32 || special.charCodeAt(i) > 126)
{
- throw new Error("special characters must be in ASCII range 32-126");
+ throw new RangeError("special characters must be in ASCII range 32-126");
}
}
}
@@ -268,7 +268,7 @@ Ice.StringUtil = class
const n = parseInt(s, 10);
if(isNaN(n))
{
- throw new Error("conversion of `" + s + "' to int failed");
+ throw new RangeError("conversion of `" + s + "' to int failed");
}
return n;
}
@@ -420,7 +420,7 @@ function checkChar(s, pos)
msg = "first character";
}
msg += " has invalid ordinal value" + c;
- throw new Error(msg);
+ throw new RangeError(msg);
}
return s.charAt(pos);
}
@@ -532,11 +532,11 @@ function decodeChar(s, start, end, special, result)
}
if(size > 0)
{
- throw new Error("Invalid universal character name: too few hex digits");
+ throw new RangeError("Invalid universal character name: too few hex digits");
}
if(codePoint >= 0xD800 && codePoint <= 0xDFFF)
{
- throw new Error("A universal character name cannot designate a surrogate");
+ throw new RangeError("A universal character name cannot designate a surrogate");
}
if(inBMP || codePoint <= 0xFFFF)
{
@@ -593,7 +593,7 @@ function decodeChar(s, start, end, special, result)
}
if(size === 2)
{
- throw new Error("Invalid \\x escape sequence: no hex digit");
+ throw new RangeError("Invalid \\x escape sequence: no hex digit");
}
}
else
@@ -611,7 +611,7 @@ function decodeChar(s, start, end, special, result)
}
if(val > 255)
{
- throw new Error("octal value \\" + val.toString(8) + " (" + val + ") is out of range");
+ throw new RangeError("octal value \\" + val.toString(8) + " (" + val + ") is out of range");
}
}