Author: reebalazs
Date: Wed Aug 29 11:18:03 2007
New Revision: 46140

Modified:
   kukit/kukit.js/trunk/kukit/commandprocessor.js
   kukit/kukit.js/trunk/kukit/errors.js
   kukit/kukit.js/trunk/kukit/eventreg.js
   kukit/kukit.js/trunk/kukit/kssparser.js
   kukit/kukit.js/trunk/kukit/resourcedata.js
   kukit/kukit.js/trunk/kukit/serveraction.js
   kukit/kukit.js/trunk/kukit/tokenizer.js
Log:
Replace string exceptions with proper ones

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 11:18:03 2007
@@ -39,7 +39,7 @@
         // we make sure we execute none of them.
         var lastcommand = this.commands[this.commands.length-1];
         if (lastcommand.name == 'error') {
-;;;         throw kukit.err.ExplicitError(lastcommand);
+;;;         throw kukit.err.explicitError(lastcommand);
             throw new Error(kukit.E);
         }
     }
@@ -126,7 +126,7 @@
 ;;;             throw(e);
 ;;;         } else {
 ;;;             // augment the error message
-;;;             throw kukit.err.CommandExecutionError(e, command); 
+;;;             throw kukit.err.commandExecutionError(e, command); 
 ;;;         }
 ;;;     }
     }

Modified: kukit/kukit.js/trunk/kukit/errors.js
==============================================================================
--- kukit/kukit.js/trunk/kukit/errors.js        (original)
+++ kukit/kukit.js/trunk/kukit/errors.js        Wed Aug 29 11:18:03 2007
@@ -22,28 +22,37 @@
 /* 
 * Exception factory 
 *
-* Create exception types:
+* Create exception helpers:
 *
-* myError = kukit.err.exceptionFactory("myError", "My special error: ");
+*    this.explicitError = function(errorcommand){
+*        var info = {'foo': 'blah'};
+*        return setErrorInfo(null, 'ExplicitError', message, info);
+*     };
 *
+>
 * Throwing:
 *    (There is no longer a "new" before creating the exception.)
 *
-* throw myError("There was an error in my program.");
+* throw kukit.mymodule.explicitError("There was an error in my program.");
 *
 * Catching example:
 *
 *   ...
 *    } catch(e) {
-*        if (e.name == 'JSONRPCError') {
+*        if (e.name == 'explicitError') {
 *            ...
 *        } else {
 *            throw(e);
 *        }
 *    }
 *
+* It is allowed to make a new error from a previous one, see examples in this 
file.
+* However you should use annotation and always throw back the original error,
+* otherwise traceback information will be lost.
+*
 */
 
+
 ;;; var ErrorAnnotation = function() {
 ;;;
 ;;;     this.constructError = function(e, name, message, info) {
@@ -91,27 +100,27 @@
 
 /* Protects a function */
 
-;;; this.ExplicitError = function(errorcommand){
+;;; this.explicitError = function(errorcommand){
 ;;;    var info = {'errorcommand':errorcommand};
 ;;;    var message = 'Explicit error';
 ;;;    return setErrorInfo(null, 'ExplicitError', message, info);
 ;;; };
 
 
-;;; this.ResponseParsingError = function(message){
+;;; this.responseParsingError = function(message){
 ;;;    return setErrorInfo(null, 'ResponseParsingError', message);
 ;;; };
 
-;;; this.RuleMergeError = function(message){
+;;; this.ruleMergeError = function(message){
 ;;;    return setErrorInfo(null, 'RuleMergeError', message);
 ;;; };
 
-;;; this.KssSelectorError = function(message){
+;;; this.kssSelectorError = function(message){
 ;;;    return setErrorInfo(null, 'RuleMergeError', message);
 ;;; };
 
 
-;;; this.ParsingError = function(message, cursor){
+;;; this.parsingError = function(message, cursor){
 ;;;    var info = {}
 ;;;    if (cursor) {
 ;;;         info.errpos = cursor.pos;
@@ -129,13 +138,13 @@
 
 /* Exceptions that re-throw (annotate) an already caught error */
 
-;;; this.CommandExecutionError = function(e, command){
+;;; this.commandExecutionError = function(e, command){
 ;;;    var message = 'Command [' + command.name + '] failed';
 ;;;    return setErrorInfo(e, 'CommandExecutionError', message);
 ;;; };
 
 
-;;; this.EventBindError = function(e, eventNames, eventNamespaces){
+;;; this.eventBindError = function(e, eventNames, eventNamespaces){
 ;;;    var info = {};
 ;;;    info.eventNames = eventNames;
 ;;;    info.eventNamespaces = eventNamespaces;
@@ -145,19 +154,19 @@
 ;;; };
 
 
-;;; this.UndefinedEventError = function(e, message){
+;;; this.undefinedEventError = function(e, message){
 ;;;    return setErrorInfo(e, 'UndefinedEventError', message);
 ;;; };
 
 
-;;; this.KssParsingError = function(e, url){
+;;; this.kssParsingError = function(e, url){
 ;;;    var info = {url: url}
 ;;;    var message = 'Error parsing KSS at ' + url;
 ;;;    return setErrorInfo(e, 'KssParsingError', message);
 ;;; };
 
 
-;;; this.EventSetupError = function(e, message){
+;;; this.eventSetupError = function(e, message){
 ;;;    var message = 'Error setting up events';
 ;;;    return setErrorInfo(e, 'EventSetupError', message);
 ;;; };

Modified: kukit/kukit.js/trunk/kukit/eventreg.js
==============================================================================
--- kukit/kukit.js/trunk/kukit/eventreg.js      (original)
+++ kukit/kukit.js/trunk/kukit/eventreg.js      Wed Aug 29 11:18:03 2007
@@ -759,7 +759,7 @@
 ;;; } catch(e) {
 ;;;     var names = eventSet.names;
 ;;;     var namespace = eventSet.namespace;
-;;;     kukit.E = kukit.err.rd.EventBindError(e, names, namespace);
+;;;     kukit.E = kukit.err.eventBindError(e, names, namespace);
 ;;;     throw new Error(kukit.E);
 ;;; }
 };

Modified: kukit/kukit.js/trunk/kukit/kssparser.js
==============================================================================
--- kukit/kukit.js/trunk/kukit/kssparser.js     (original)
+++ kukit/kukit.js/trunk/kukit/kssparser.js     Wed Aug 29 11:18:03 2007
@@ -707,14 +707,14 @@
 ;;;                     kukit.E += rule.kssSelector.namespace + ':';
 ;;;             }
 ;;;             kukit.E += rule.kssSelector.name + '].';
-;;;             throw kukit.err.UndefinedEventError(e, kukit.E);
+;;;             throw kukit.err.undefinedEventError(e, kukit.E);
 ;;;         }
             this.rules.push(rule);
         }
 ;;; } catch(e) {
 ;;;    // ParsingError are logged.
 ;;;    if (e.name == 'ParsingError' || e.name == 'UndefinedEventError') {
-;;;        throw kukit.err.KssParsingError(e, this.href);
+;;;        throw kukit.err.kssParsingError(e, this.href);
 ;;;    } else {
 ;;;        throw e;
 ;;;    }

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 11:18:03 2007
@@ -46,23 +46,23 @@
     }
 ;;; if (name.indexOf('@') != -1) {
 ;;;     var msg = 'Kss selector name must not contain @: [' + name + '].';
-;;;     throw kukit.err.rd.KssSelectorError(msg);
+;;;     throw kukit.err.kssSelectorError(msg);
 ;;;     }
 ;;; if (id && id.indexOf('@') != -1) {
 ;;;     var msg = 'Kss selector id must not contain @: [' + id + '].';
-;;;     throw kukit.err.rd.KssSelectorError(msg);
+;;;     throw kukit.err.kssSelectorError(msg);
 ;;;     }
 ;;; if (namespace && namespace.indexOf('@') != -1) {
 ;;;     var msg = 'Kss selector namespace must not contain @: [' + namespace;
 ;;;     msg = msg + '].';
-;;;     throw kukit.err.rd.KssSelectorError(msg);
+;;;     throw kukit.err.kssSelectorError(msg);
 ;;;    }
 ;;; if (! isEvent) {
 ;;;     // method rule
 ;;;     if (css != 'document' && css != 'behaviour') {
 ;;;         var msg = 'KssSpecialSelector [' + name;
 ;;;         msg = msg + '] must have one of the allowed names';
-;;;         throw kukit.err.rd.KssSelectorError(msg);
+;;;         throw kukit.err.kssSelectorError(msg);
 ;;;    }
 ;;; }
     this.css = css;
@@ -375,7 +375,9 @@
             } else {
 ;;;             var msg = 'Cannot action-delete unexisting action, [';
 ;;;             msg = msg + key + '].';
-;;;             throw kukit.err.rd.RuleMergeError(msg);
+;;;             // Double throw in this case is needed, in production mode
+;;;             // only the second one will be effective.
+;;;             throw kukit.err.ruleMergeError(msg);
                 throw new Error(kukit.E);
             }
         }
@@ -460,14 +462,14 @@
 ;;; if (this.name != null && this.name != name) {
 ;;;     var msg = 'Error overriding action name [' + this.name;
 ;;;     msg = msg + '] to [' + name + '] (Unmatching action names at merge?)';
-;;;     throw kukit.err.rd.RuleMergeError(msg);
+;;;     throw kukit.err.ruleMergeError(msg);
 ;;; }
     this.name = name;
     if (name == 'default') {
 ;;;     if (this.type != null && this.type != 'D') {
 ;;;         var msg = 'Error setting action to default on action [' + 
this.name;
 ;;;         msg = msg + '], current type [' + this.type + '].';
-;;;         throw kukit.err.rd.RuleMergeError(msg);
+;;;         throw kukit.err.ruleMergeError(msg);
 ;;;     }
         this.setType('D');
     }
@@ -492,12 +494,12 @@
 ;;;     var msg = 'Error setting action type on action [' + this.name;
 ;;;     msg = msg + '] from [' + this.type + '] to [' + type;
 ;;;     msg = msg + '] (Attempt to merge client, server or error actions ?)';
-;;;     throw kukit.err.rd.RuleMergeError(msg);
+;;;     throw kukit.err.ruleMergeError(msg);
 ;;; }
 ;;; if (this.error != null && this.type != 'S') {
 ;;;     var msg = 'Error setting action error handler on action [' + this.name;
 ;;;     msg = msg + '], this is only allowed on server actions.';
-;;;     throw kukit.err.rd.RuleMergeError(msg);
+;;;     throw kukit.err.ruleMergeError(msg);
 ;;; }
     this.type = type;  
 };
@@ -506,7 +508,7 @@
 ;;; if (this.type != null && this.type != 'S') {
 ;;;     var msg = 'Error setting action error handler on action [' + this.name;
 ;;;     msg =  msg + '], this is only allowed on server actions.';
-;;;     throw kukit.err.rd.RuleMergeError(msg);
+;;;     throw kukit.err.ruleMergeError(msg);
 ;;; }
     this.error = error;  
 };

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 11:18:03 2007
@@ -116,7 +116,7 @@
                 this.processResult(domDoc);
 ;;;         } catch(e) {
 ;;;             if (e.name == 'RuleMergeError' || e.name == 'EventBindError') {
-;;;                 throw kukit.err.EventSetupError(e);
+;;;                 throw kukit.err.eventSetupError(e);
 ;;;             } else if (e.name == 'ResponseParsingError') {
 ;;;                 this.processError('Response parsing error: ' + e);
 ;;;             } else if (e.name == 'ExplicitError') {
@@ -152,7 +152,7 @@
                 dom = (new DOMParser()).parseFromString(payload, "text/xml");
             } catch(e) {
 ;;;             var msg = 'Error parsing X-KSSCOMMANDS header.';
-;;;             throw kukit.err.ResponseParsingError(msg);
+;;;             throw kukit.err.responseParsingError(msg);
                 throw new Error(kukit.E);
             }
             commandstags = kukit.dom.getNsTags(dom, 'commands');
@@ -172,14 +172,14 @@
 ;;;         if (dom && dom.parseError && (dom.parseError != 0)) {
 ;;;             msg += ' : ' + Sarissa.getParseErrorText(dom);
 ;;;             }
-;;;         throw kukit.err.ResponseParsingError(msg);
+;;;         throw kukit.err.responseParsingError(msg);
             throw new Error(kukit.E);
         }
     }
     if (dom == null) {
         // this should not happen
 ;;;     var msg = 'Neither xml nor html payload.';
-;;;     throw kukit.err.ResponseParsingError(msg);
+;;;     throw kukit.err.responseParsingError(msg);
         throw new Error(kukit.E);
     }
     // find the commands (atm we don't limit ourselves inside the commandstag)

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 11:18:03 2007
@@ -30,7 +30,7 @@
 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);
-;;; throw kukit.err.ParsingError(msg, marker);
+;;; throw kukit.err.parsingError(msg, marker);
     throw new Error(kukit.E);
 };
 
_______________________________________________
Kukit-checkins mailing list
[email protected]
http://codespeak.net/mailman/listinfo/kukit-checkins

Reply via email to