Author: jvloothuis
Date: Wed Aug 29 10:58:55 2007
New Revision: 46135
Modified:
kukit/kukit.js/trunk/kukit/commandprocessor.js
kukit/kukit.js/trunk/kukit/kukit.js
kukit/kukit.js/trunk/kukit/plugin.js
kukit/kukit.js/trunk/kukit/resourcedata.js
kukit/kukit.js/trunk/kukit/selectorreg.js
kukit/kukit.js/trunk/kukit/serveraction.js
kukit/kukit.js/trunk/kukit/tokenizer.js
kukit/kukit.js/trunk/kukit/utils.js
Log:
Changed string errors to error objects for the new exception handling
Modified: kukit/kukit.js/trunk/kukit/commandprocessor.js
==============================================================================
--- kukit/kukit.js/trunk/kukit/commandprocessor.js (original)
+++ kukit/kukit.js/trunk/kukit/commandprocessor.js Wed Aug 29 10:58:55 2007
@@ -39,8 +39,8 @@
// we make sure we execute none of them.
var lastcommand = this.commands[this.commands.length-1];
if (lastcommand.name == 'error') {
-;;; kukit.E = new kukit.err.ExplicitError(lastcommand);
- throw kukit.E;
+;;; throw kukit.err.ExplicitError(lastcommand);
+ throw new Error(kukit.E);
}
}
};
@@ -65,12 +65,12 @@
// (here tolerate both cases)
if (childNode.localName.toLowerCase() != "param"
&& childNode.nodeName.toLowerCase() != "kukit:param") {
- throw 'Bad payload, expected param';
+ throw new Error('Bad payload, expected param');
}
} else {
//IE does not know DOM2
if (childNode.nodeName.toLowerCase() != "kukit:param") {
- throw 'Bad payload, expected kukit:param';
+ throw new Error('Bad payload, expected kukit:param');
}
}
data = childNode.getAttribute('name');
@@ -89,7 +89,7 @@
;;; var isCData = childNode.firstChild.nodeType == 4;
;;; if (! (childCount == 1 && (isTextNode || isCData))) {
;;; kukit.E = 'Bad payload, expected a text or a CDATA
node';
- ;;; throw kukit.E;
+ ;;; throw new Error(kukit.E);
;;; }
// we consider this as html payload
// The result is always a string from here.
@@ -97,7 +97,7 @@
}
params[data] = result;
} else {
- throw 'Bad payload, expected attribute "name"';
+ throw new Error('Bad payload, expected attribute "name"');
}
}
var command = new kukit.cr.makeCommand(selector, name, type, params,
Modified: kukit/kukit.js/trunk/kukit/kukit.js
==============================================================================
--- kukit/kukit.js/trunk/kukit/kukit.js (original)
+++ kukit/kukit.js/trunk/kukit/kukit.js Wed Aug 29 10:58:55 2007
@@ -267,7 +267,7 @@
;;; // Log the message
;;; kukit.logFatal(msg);
;;; // and throw it...
-;;; throw msg;
+ ;;; throw new Error(msg);
;;; } else {
;;; throw e;
;;; }
Modified: kukit/kukit.js/trunk/kukit/plugin.js
==============================================================================
--- kukit/kukit.js/trunk/kukit/plugin.js (original)
+++ kukit/kukit.js/trunk/kukit/plugin.js Wed Aug 29 10:58:55 2007
@@ -141,7 +141,7 @@
kukit.pl.NativeEventBinder.prototype.__bind__node =
function(name, func_to_bind, oper) {
;;; if (oper.node == null) {
-;;; throw 'Native event [' + name + '] must be bound to a node.';
+;;; throw new Error('Native event [' + name + '] must be bound to a
node.');
;;; }
this.__bind__(name, func_to_bind, oper);
};
@@ -157,7 +157,7 @@
kukit.pl.NativeEventBinder.prototype.__bind__window =
function(name, func_to_bind, oper) {
;;; if (oper.node != null) {
-;;; throw 'Native event [' + name + '] must not be bound to a node.';
+;;; throw new Error('Native event [' + name + '] must not be bound to a
node.');
;;; }
oper.node = window;
this.__bind__(name, func_to_bind, oper);
@@ -183,7 +183,7 @@
if (name != 'click') {
;;; kukit.E = 'In native events only the click event can have';
;;; kukit.E += ' [preventdefault] parameter.';
- throw kukit.E;
+ throw new Error(kukit.E);
}
}
kukit.pl.registerBrowserEvent(oper);
@@ -410,7 +410,7 @@
// Not an iframe. So iload is not usable.
if (iloadoper) {
;;; kukit.E = '[iload] event can only be bound to an iframe node.';
- throw kukit.E;
+ throw new Error(kukit.E);
}
}
// Now, bind the events.
@@ -540,7 +540,7 @@
* They also get registered as commands
*/
kukit.actionsGlobalRegistry.register('error', function (oper) {
- throw 'The builtin error action should never execute.';
+ throw new Error('The builtin error action should never execute.');
}
);
kukit.commandsGlobalRegistry.registerFromAction('error',
@@ -640,7 +640,7 @@
oper.evaluateParameters(['name', 'value'], {});
if (oper.parms.name.toLowerCase() == 'style') {
;;; kukit.E = '[style] attribute is not allowed with [setAttribute]';
- throw kukit.E;
+ throw new Error(kukit.E);
}
kukit.dom.setAttribute(oper.node, oper.parms.name,
oper.parms.value);
Modified: kukit/kukit.js/trunk/kukit/resourcedata.js
==============================================================================
--- kukit/kukit.js/trunk/kukit/resourcedata.js (original)
+++ kukit/kukit.js/trunk/kukit/resourcedata.js Wed Aug 29 10:58:55 2007
@@ -42,7 +42,7 @@
this.isEventSelector = isEvent;
this.isMethodSelector = ! isEvent;
if (! name) {
- throw 'KssSelector must have name';
+ throw new Error('KssSelector must have name');
}
;;; if (name.indexOf('@') != -1) {
;;; var msg = 'Kss selector name must not contain @: [' + name + '].';
@@ -303,18 +303,18 @@
kukit.rd.EventRule.prototype.merge = function(other) {
;;; if (! this.isMerged()) {
-;;; throw 'Cannot merge into a genuine event rule';
+;;; throw new Error('Cannot merge into a genuine event rule');
;;; }
;;; if (this.kssSelector.isEventSelector) {
;;; if (this.kssSelector.id != other.kssSelector.id) {
-;;; throw 'Differing kss selector ids in event rule merge';
+;;; throw new Error('Differing kss selector ids in event rule merge');
;;; }
;;; if (this.kssSelector.className != other.kssSelector.className) {
-;;; throw 'Differing kss selector classes in event rule merge';
+;;; throw new Error('Differing kss selector classes in event rule
merge');
;;; }
;;; }
;;; if (this.kssSelector.name != other.kssSelector.name) {
-;;; throw 'Differing kss selector names in event rule merge';
+;;; throw new Error('Differing kss selector names in event rule merge');
;;; }
this.mergedIndex = this.mergedIndex + ',' + other.getIndex();
for (var key in other.parms) {
@@ -375,8 +375,8 @@
} else {
;;; var msg = 'Cannot action-delete unexisting action, [';
;;; msg = msg + key + '].';
-;;; kukit.E = new kukit.err.rd.RuleMergeError(msg);
- throw kukit.E;
+;;; throw kukit.err.rd.RuleMergeError(msg);
+ throw new Error(kukit.E);
}
}
if (action2.type != 'X') {
@@ -430,7 +430,7 @@
kukit.rd.ActionSet.prototype.deleteAction = function(name) {
var action = this.content[name];
;;; if (typeof(action) == 'undefined') {
-;;; throw('Action [' + name + '] does not exist and cannot be deleted.');
+;;; throw new Error('Action [' + name + '] does not exist and cannot be
deleted.');
;;; }
delete this.content[name];
@@ -731,7 +731,7 @@
var category = eventRule.kssSelector.css;
var dict = this.content[category];
;;; if (typeof(dict) == 'undefined') {
-;;; throw 'Unknown method rule category [' + category + '].';
+;;; throw new Error('Unknown method rule category [' + category + '].');
;;; }
// Merge into the corresponding category
eventRule.mergeIntoDict(dict, eventRule.kssSelector.mergeId, eventRule);
@@ -744,7 +744,7 @@
// Get the entry by category (= document or behaviour)
var dict = this.content[category];
;;; if (typeof(dict) == 'undefined') {
-;;; throw 'Unknown method rule category [' + category + '].';
+;;; throw new Error('Unknown method rule category [' + category + '].');
;;; }
// look up the rule
var namespace = binderInstance.__eventNamespace__;
Modified: kukit/kukit.js/trunk/kukit/selectorreg.js
==============================================================================
--- kukit/kukit.js/trunk/kukit/selectorreg.js (original)
+++ kukit/kukit.js/trunk/kukit/selectorreg.js Wed Aug 29 10:58:55 2007
@@ -31,7 +31,7 @@
check: function(args) {
// check does not need to be used here actually.
;;; if (args.length != 1) {
-;;; throw 'internal error, xxxselector() needs 1 argument';
+;;; throw new Error('internal error, xxxselector() needs 1 argument');
;;; }
},
eval: function(args, node, defaultParameters) {
@@ -58,7 +58,7 @@
kukit.sr.PassnodePP.prototype = {
check: function(args) {
;;; if (args.length != 1) {
-;;; throw 'passnode selector method needs 1 argument';
+;;; throw new Error('passnode selector method needs 1 argument');
;;; }
},
eval: function(args, node, defaultParameters) {
@@ -66,7 +66,7 @@
if (typeof(value) == 'undefined') {
// notfound arguments will get null
;;; kukit.E = 'Nonexistent default parm "'+ key +'"';
- throw kukit.E;
+ throw new Error(kukit.E);
}
nodes = [value];
return nodes;
@@ -93,7 +93,7 @@
kukit.sr.SelectorTypeRegistry.prototype.register = function(name, func) {
if (typeof(func) == 'undefined') {
- throw 'Func is mandatory.';
+ throw new Error('Func is mandatory.');
}
;;; if (this.mapping[name]) {
;;; // Do not allow redefinition
@@ -114,7 +114,7 @@
}
var result = this.mapping[name];
;;; if (typeof(result) == 'undefined') {
-;;; throw 'Unknown selector type "' + name + '"';
+;;; throw new Error('Unknown selector type "' + name + '"');
;;; }
return result;
};
Modified: kukit/kukit.js/trunk/kukit/serveraction.js
==============================================================================
--- kukit/kukit.js/trunk/kukit/serveraction.js (original)
+++ kukit/kukit.js/trunk/kukit/serveraction.js Wed Aug 29 10:58:55 2007
@@ -152,8 +152,8 @@
dom = (new DOMParser()).parseFromString(payload, "text/xml");
} catch(e) {
;;; var msg = 'Error parsing X-KSSCOMMANDS header.';
-;;; kukit.E = new kukit.err.ResponseParsingError(msg);
- throw kukit.E;
+;;; throw new kukit.err.ResponseParsingError(msg);
+ throw new Error(kukit.E);
}
commandstags = kukit.dom.getNsTags(dom, 'commands');
if (commandstags.length != 1) {
@@ -172,15 +172,15 @@
;;; if (dom && dom.parseError && (dom.parseError != 0)) {
;;; msg += ' : ' + Sarissa.getParseErrorText(dom);
;;; }
-;;; kukit.E = new kukit.err.ResponseParsingError(msg);
- throw kukit.E;
+;;; throw kukit.err.ResponseParsingError(msg);
+ throw new Error(kukit.E);
}
}
if (dom == null) {
// this should not happen
;;; var msg = 'Neither xml nor html payload.';
-;;; kukit.E = new kukit.err.ResponseParsingError(msg);
- throw kukit.E;
+;;; throw new kukit.err.ResponseParsingError(msg);
+ throw new Error(kukit.E);
}
// find the commands (atm we don't limit ourselves inside the commandstag)
var commands = kukit.dom.getNsTags(dom, 'command');
Modified: kukit/kukit.js/trunk/kukit/tokenizer.js
==============================================================================
--- kukit/kukit.js/trunk/kukit/tokenizer.js (original)
+++ kukit/kukit.js/trunk/kukit/tokenizer.js Wed Aug 29 10:58:55 2007
@@ -30,8 +30,8 @@
kukit.tk._TokenBase.prototype.emitError = function(msg) {
// Use the start position of the token for the error report.
;;; var marker = this.src.makeMarker(this.startpos);
-;;; kukit.E = new kukit.err.tk.ParsingError(msg, marker);
- throw kukit.E;
+;;; throw kukit.err.ParsingError(msg, marker);
+ throw new Error(kukit.E);
};
kukit.tk._TokenBase.prototype.setSrcStatus = function(eofOk) {
Modified: kukit/kukit.js/trunk/kukit/utils.js
==============================================================================
--- kukit/kukit.js/trunk/kukit/utils.js (original)
+++ kukit/kukit.js/trunk/kukit/utils.js Wed Aug 29 10:58:55 2007
@@ -254,7 +254,7 @@
|| value == '') {
value = false;
;;; } else {
-;;; throw 'Bad boolean value "' + value + '" ' + errname;
+;;; throw new Error('Bad boolean value "' + value + '" ' + errname);
}
return value;
};
@@ -263,7 +263,7 @@
;;; try {
value = parseInt(value);
;;; } catch(e) {
-;;; throw 'Bad integer value "' + value + '" ' + errname;
+;;; throw new Error('Bad integer value "' + value + '" ' + errname);
;;; }
return value;
};
@@ -279,7 +279,7 @@
// do the splitting
value = value.split(/ *, */);
;;; } catch(e) {
-;;; throw 'Bad list value "' + value + '" ' + errname;
+;;; throw new Error('Bad list value "' + value + '" ' + errname);
;;; }
return value;
};
@@ -305,7 +305,7 @@
if (this.timer) {
;;; kukit.E = 'Timer already started.';
- throw kukit.E;
+ throw new Error(kukit.E);
}
var self = this;
var func = function() {
_______________________________________________
Kukit-checkins mailing list
[email protected]
http://codespeak.net/mailman/listinfo/kukit-checkins