summaryrefslogtreecommitdiff
path: root/js/src/Ice/Exception.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/Ice/Exception.js')
-rw-r--r--js/src/Ice/Exception.js399
1 files changed, 196 insertions, 203 deletions
diff --git a/js/src/Ice/Exception.js b/js/src/Ice/Exception.js
index 929b0b22790..98fe8b9ed26 100644
--- a/js/src/Ice/Exception.js
+++ b/js/src/Ice/Exception.js
@@ -7,235 +7,228 @@
//
// **********************************************************************
-(function(global){
- require("Ice/Class");
-
- var Slice = global.Slice || {};
- var Ice = global.Ice || {};
+var Ice = require("../Ice/Class").Ice;
+var Class = Ice.Class;
- var Class = Ice.Class;
-
- //
- // Ice.Exception
- //
- var Exception = Class(Error, {
- __init__: function(cause)
- {
- this.ice_cause = cause;
- },
- ice_name: function()
- {
- return "Ice::Exception";
- },
- toString: function()
+//
+// Ice.Exception
+//
+var Exception = Class(Error, {
+ __init__: function(cause)
+ {
+ this.ice_cause = cause;
+ },
+ ice_name: function()
+ {
+ return "Ice::Exception";
+ },
+ toString: function()
+ {
+ var s = this.ice_name();
+ for(var key in this)
{
- var s = this.ice_name();
- for(var key in this)
+ if(key == "stack" || key.indexOf("_") === 0)
{
- if(key == "stack" || key.indexOf("_") === 0)
- {
- continue;
- }
-
- var value = this[key];
- if(typeof value == "function")
- {
- continue;
- }
-
- s += "\n " + key + ": \"" + value + "\"";
+ continue;
}
- return s;
- }
- });
-
- Exception.captureStackTrace = function(object)
- {
- var stack = new Error().stack;
-
- var formattedStack;
-
- //
- // In IE 10 and greater the stack will be filled once the Error is throw
- // we don't need to do anything.
- //
- if(stack !== undefined)
- {
-
- var name = object.ice_name ? object.ice_name().replace(/::/g, ".") : "";
- Object.defineProperty(object, "stack", {
- get: function(){
- return stack;
- }
- });
- }
- };
- Ice.Exception = Exception;
+ var value = this[key];
+ if(typeof value == "function")
+ {
+ continue;
+ }
- //
- // Ice.LocalException
- //
- var LocalException = Class(Exception, {
- __init__: function(cause)
- {
- Exception.call(this, cause);
- Exception.captureStackTrace(this);
- },
- ice_name: function()
- {
- return "Ice::LocalException";
+ s += "\n " + key + ": \"" + value + "\"";
}
- });
-
- Ice.LocalException = LocalException;
-
- Slice.defineLocalException = function(constructor, base, name)
- {
- var ex = constructor;
- ex.prototype = new base();
- ex.prototype.constructor = ex;
- ex.prototype.ice_name = function()
- {
- return name;
- };
- return ex;
- };
+ return s;
+ }
+});
- //
- // Ice.UserException
- //
- var UserException = Class(Exception, {
- __init__: function(cause)
- {
- Exception.call(this, cause);
- Exception.captureStackTrace(this);
- },
- ice_name: function()
- {
- return "Ice::UserException";
- },
- __write: function(os)
- {
- os.startWriteException(null);
- __writeImpl(this, os, this.__mostDerivedType());
- os.endWriteException();
- },
- __read: function(is)
- {
- is.startReadException();
- __readImpl(this, is, this.__mostDerivedType());
- is.endReadException(false);
- },
- __usesClasses: function()
- {
- return false;
- }
- });
- Ice.UserException = UserException;
+Exception.captureStackTrace = function(object)
+{
+ var stack = new Error().stack;
+
+ var formattedStack;
//
- // Private methods
+ // In IE 10 and greater the stack will be filled once the Error is throw
+ // we don't need to do anything.
//
-
- var __writeImpl = function(obj, os, type)
+ if(stack !== undefined)
{
- //
- // The __writeImpl method is a recursive method that goes down the
- // class hierarchy to marshal each slice of the class using the
- // generated __writeMemberImpl method.
- //
- if(type === undefined || type === UserException)
- {
- return; // Don't marshal anything for Ice.UserException
- }
+ var name = object.ice_name ? object.ice_name().replace(/::/g, ".") : "";
+ Object.defineProperty(object, "stack", {
+ get: function(){
+ return stack;
+ }
+ });
+ }
+};
- os.startWriteSlice(type.__id, -1, type.__parent === UserException);
- if(type.prototype.__writeMemberImpl)
- {
- type.prototype.__writeMemberImpl.call(obj, os);
- }
- os.endWriteSlice();
- __writeImpl(obj, os, type.__parent);
- };
+Ice.Exception = Exception;
- var __readImpl = function(obj, is, type)
+//
+// Ice.LocalException
+//
+var LocalException = Class(Exception, {
+ __init__: function(cause)
{
- //
- // The __readImpl method is a recursive method that goes down the
- // class hierarchy to marshal each slice of the class using the
- // generated __readMemberImpl method.
- //
-
- if(type === undefined || type === UserException)
- {
- return; // Don't marshal anything for UserException
- }
-
- is.startReadSlice();
- if(type.prototype.__readMemberImpl)
- {
- type.prototype.__readMemberImpl.call(obj, is);
- }
- is.endReadSlice();
- __readImpl(obj, is, type.__parent);
+ Exception.call(this, cause);
+ Exception.captureStackTrace(this);
+ },
+ ice_name: function()
+ {
+ return "Ice::LocalException";
+ }
+});
+
+Ice.LocalException = LocalException;
+
+var Slice = Ice.Slice;
+Slice.defineLocalException = function(constructor, base, name)
+{
+ var ex = constructor;
+ ex.prototype = new base();
+ ex.prototype.constructor = ex;
+ ex.prototype.ice_name = function()
+ {
+ return name;
};
-
- var __writePreserved = function(os)
+ return ex;
+};
+
+//
+// Ice.UserException
+//
+var UserException = Class(Exception, {
+ __init__: function(cause)
+ {
+ Exception.call(this, cause);
+ Exception.captureStackTrace(this);
+ },
+ ice_name: function()
{
- //
- // For Slice exceptions which are marked "preserved", the implementation of this method
- // replaces the Ice.Object.prototype.__write method.
- //
- os.startWriteException(this.__slicedData);
+ return "Ice::UserException";
+ },
+ __write: function(os)
+ {
+ os.startWriteException(null);
__writeImpl(this, os, this.__mostDerivedType());
os.endWriteException();
- };
-
- var __readPreserved = function(is)
+ },
+ __read: function(is)
{
- //
- // For Slice exceptions which are marked "preserved", the implementation of this method
- // replaces the Ice.Object.prototype.__read method.
- //
is.startReadException();
__readImpl(this, is, this.__mostDerivedType());
- this.__slicedData = is.endReadException(true);
+ is.endReadException(false);
+ },
+ __usesClasses: function()
+ {
+ return false;
+ }
+});
+Ice.UserException = UserException;
+
+//
+// Private methods
+//
+
+var __writeImpl = function(obj, os, type)
+{
+ //
+ // The __writeImpl method is a recursive method that goes down the
+ // class hierarchy to marshal each slice of the class using the
+ // generated __writeMemberImpl method.
+ //
+
+ if(type === undefined || type === UserException)
+ {
+ return; // Don't marshal anything for Ice.UserException
+ }
+
+ os.startWriteSlice(type.__id, -1, type.__parent === UserException);
+ if(type.prototype.__writeMemberImpl)
+ {
+ type.prototype.__writeMemberImpl.call(obj, os);
+ }
+ os.endWriteSlice();
+ __writeImpl(obj, os, type.__parent);
+};
+
+var __readImpl = function(obj, is, type)
+{
+ //
+ // The __readImpl method is a recursive method that goes down the
+ // class hierarchy to marshal each slice of the class using the
+ // generated __readMemberImpl method.
+ //
+
+ if(type === undefined || type === UserException)
+ {
+ return; // Don't marshal anything for UserException
+ }
+
+ is.startReadSlice();
+ if(type.prototype.__readMemberImpl)
+ {
+ type.prototype.__readMemberImpl.call(obj, is);
+ }
+ is.endReadSlice();
+ __readImpl(obj, is, type.__parent);
+};
+
+var __writePreserved = function(os)
+{
+ //
+ // For Slice exceptions which are marked "preserved", the implementation of this method
+ // replaces the Ice.Object.prototype.__write method.
+ //
+ os.startWriteException(this.__slicedData);
+ __writeImpl(this, os, this.__mostDerivedType());
+ os.endWriteException();
+};
+
+var __readPreserved = function(is)
+{
+ //
+ // For Slice exceptions which are marked "preserved", the implementation of this method
+ // replaces the Ice.Object.prototype.__read method.
+ //
+ is.startReadException();
+ __readImpl(this, is, this.__mostDerivedType());
+ this.__slicedData = is.endReadException(true);
+};
+
+Slice.defineUserException = function(constructor, base, name, writeImpl, readImpl, preserved, usesClasses)
+{
+ var ex = constructor;
+ ex.__parent = base;
+ ex.prototype = new base();
+ ex.__id = "::" + name;
+ ex.prototype.ice_name = function()
+ {
+ return name;
};
- Slice.defineUserException = function(constructor, base, name, writeImpl, readImpl, preserved, usesClasses)
+ ex.prototype.constructor = ex;
+ ex.prototype.__mostDerivedType = function() { return ex; };
+ if(preserved)
{
- var ex = constructor;
- ex.__parent = base;
- ex.prototype = new base();
- ex.__id = "::" + name;
- ex.prototype.ice_name = function()
- {
- return name;
- };
-
- ex.prototype.constructor = ex;
- ex.prototype.__mostDerivedType = function() { return ex; };
- if(preserved)
- {
- ex.prototype.__write = __writePreserved;
- ex.prototype.__read = __readPreserved;
- }
- ex.prototype.__writeMemberImpl = writeImpl;
- ex.prototype.__readMemberImpl = readImpl;
+ ex.prototype.__write = __writePreserved;
+ ex.prototype.__read = __readPreserved;
+ }
+ ex.prototype.__writeMemberImpl = writeImpl;
+ ex.prototype.__readMemberImpl = readImpl;
- if(usesClasses)
+ if(usesClasses)
+ {
+ ex.prototype.__usesClasses = function()
{
- ex.prototype.__usesClasses = function()
- {
- return true;
- };
- }
-
- return ex;
- };
+ return true;
+ };
+ }
- global.Slice = Slice;
- global.Ice = Ice;
-}(typeof (global) === "undefined" ? window : global));
+ return ex;
+};
+module.exports.Ice = Ice;