summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2016-04-01 17:49:10 +0200
committerBenoit Foucher <benoit@zeroc.com>2016-04-01 17:49:10 +0200
commit4c0fa1dab6be9fc3ae024d3cf982fe1e521b5e2d (patch)
treeed11053b33d5c07e358dbe6a6adb2f559223318e /js
parentJS style fixes (diff)
downloadice-4c0fa1dab6be9fc3ae024d3cf982fe1e521b5e2d.tar.bz2
ice-4c0fa1dab6be9fc3ae024d3cf982fe1e521b5e2d.tar.xz
ice-4c0fa1dab6be9fc3ae024d3cf982fe1e521b5e2d.zip
Fixed issue with IE where accessing the stack from Exception.toString leads to an infinite recursionv3.6.2
Diffstat (limited to 'js')
-rw-r--r--js/src/Ice/Exception.js27
1 files changed, 17 insertions, 10 deletions
diff --git a/js/src/Ice/Exception.js b/js/src/Ice/Exception.js
index 0170e31fed8..d7967b0ff8f 100644
--- a/js/src/Ice/Exception.js
+++ b/js/src/Ice/Exception.js
@@ -33,16 +33,8 @@ var toString = function(key, object, objectTable, ident)
{
return "\n" + ident + key + ": (recursive)";
}
-
+
objectTable.push(object);
- //
- // For objects use the toString function if one is provided.
- //
- if(typeof object.toString == "function")
- {
- return "\n" + ident + key + ":" + object.toString();
- }
-
var s = "\n" + ident + key + ":";
for(var k in object)
{
@@ -77,16 +69,31 @@ var Exception = Class(Error, {
},
toString: function()
{
+ //
+ // We have a guard here to prevent being re-entered. With some browsers (IE), accessing
+ // the stack property ends up calling toString on the exception to print it out with the
+ // stack.
+ //
+ if(this._inToStringAlready)
+ {
+ return "";
+ }
+
+ this._inToStringAlready = true;
var s = this.ice_name();
for(var key in this)
{
- s += toString(key, this[key], [], "");
+ if(key != "_inToStringAlready")
+ {
+ s += toString(key, this[key], [], "");
+ }
}
if(Ice.__printStackTraces === true && this.stack)
{
s += "\n" + this.stack;
}
+ this._inToStringAlready = false;
return s;
}
});