[KSS-checkins] r49386 - in kukit/kukit.js/branch/1.2: doc kukit

reebalazs at codespeak.net reebalazs at codespeak.net
Wed Dec 5 14:52:08 CET 2007


Author: reebalazs
Date: Wed Dec  5 14:52:05 2007
New Revision: 49386

Modified:
   kukit/kukit.js/branch/1.2/doc/HISTORY.txt
   kukit/kukit.js/branch/1.2/kukit/commandprocessor.js
   kukit/kukit.js/branch/1.2/kukit/errors.js
   kukit/kukit.js/branch/1.2/kukit/serveraction.js
Log:
Fix error handling.  

Due to excess commenting, the following problems persisted:

- error fallback actions were not executed in production mode
- explicit error reason (server reason = ) was never displayed
  (neither in producttion and development mode)
- If there is a problem with the kukit response, there is no
  error signalled in production mode.
  I still could not solve this last one.

At the moment error demo works correctly.

This is backport of fix -r49377 on trunk.

Modified: kukit/kukit.js/branch/1.2/doc/HISTORY.txt
==============================================================================
--- kukit/kukit.js/branch/1.2/doc/HISTORY.txt	(original)
+++ kukit/kukit.js/branch/1.2/doc/HISTORY.txt	Wed Dec  5 14:52:05 2007
@@ -6,6 +6,9 @@
 
     - ...
 
+    - Fix error fallback handling
+      [ree]
+
     - Implement loglevels based on cookies
       Add cookie handling code to kss.dom
       Change logging on FireBug to avoid line info in debug

Modified: kukit/kukit.js/branch/1.2/kukit/commandprocessor.js
==============================================================================
--- kukit/kukit.js/branch/1.2/kukit/commandprocessor.js	(original)
+++ kukit/kukit.js/branch/1.2/kukit/commandprocessor.js	Wed Dec  5 14:52:05 2007
@@ -39,8 +39,9 @@
         // 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;
+            // We have to throw an explicitError always, since we want
+            // error fallbacks work both in production and development mode.
+            throw new kukit.err.ExplicitError(lastcommand);
         }
     }
 };

Modified: kukit/kukit.js/branch/1.2/kukit/errors.js
==============================================================================
--- kukit/kukit.js/branch/1.2/kukit/errors.js	(original)
+++ kukit/kukit.js/branch/1.2/kukit/errors.js	Wed Dec  5 14:52:05 2007
@@ -71,19 +71,19 @@
     return exc;
 };
 
-;;; // this should be thrown with the error command as parameter
-;;; kukit.err.ExplicitError = kukit.err.exceptionFactory('ExplicitError');
-;;; kukit.err.ee = kukit.err.ExplicitError;
-;;; kukit.err.ee.prototype.__superinit__ = kukit.err.ee.prototype.__init__;
-;;; kukit.err.ee.prototype.__init__ = function(name, errorcommand) {
-;;;     var message = 'Explicit error';
-;;;     var kw = this.__superinit__(name, message);
-;;;     kw.errorcommand = errorcommand;
-;;;     return kw;
-;;; };
+// this should be thrown with the error command as parameter
+kukit.err.ExplicitError = kukit.err.exceptionFactory('ExplicitError');
+kukit.err.ee = kukit.err.ExplicitError;
+kukit.err.ee.prototype.__superinit__ = kukit.err.ee.prototype.__init__;
+kukit.err.ee.prototype.__init__ = function(name, errorcommand) {
+    var message = 'Explicit error';
+    var kw = this.__superinit__(name, message);
+    kw.errorcommand = errorcommand;
+    return kw;
+};
 
-;;; var name = 'ResponseParsingError';
-;;; kukit.err.ResponseParsingError = kukit.err.exceptionFactory(name);
+var name = 'ResponseParsingError';
+kukit.err.ResponseParsingError = kukit.err.exceptionFactory(name);
 
 ;;; var name = 'CommandExecutionError';
 ;;; kukit.err.CommandExecutionError = kukit.err.exceptionFactory(name);

Modified: kukit/kukit.js/branch/1.2/kukit/serveraction.js
==============================================================================
--- kukit/kukit.js/branch/1.2/kukit/serveraction.js	(original)
+++ kukit/kukit.js/branch/1.2/kukit/serveraction.js	Wed Dec  5 14:52:05 2007
@@ -111,28 +111,35 @@
         if (success) {
             // catch the errors otherwise won't get logged.
             // In FF they seem to get swallowed silently.
-;;;         try {
+            // We need these both in production and development mode,
+            // since the erorr fallbacks are activated from processError.
+            try {
                 // process the results
                 this.processResult(domDoc);
-;;;         } catch(e) {
+            } catch(e) {
 ;;;             if (e.name == 'RuleMergeError' || e.name == 'EventBindError') {
 ;;;                 // Log the message
 ;;;                 var msg = 'Error setting up events: ' + e.toString();
 ;;;                 kukit.logFatal(msg);
 ;;;                 // just throw it too...
 ;;;                 throw msg;
-;;;             } else if (e.name == 'ResponseParsingError') {
-;;;                 this.processError('Response parsing error: ' + e);
-;;;             } else if (e.name == 'ExplicitError') {
-;;;                 this.processError(e.errorcommand);
+;;;             }
+                if (e.name == 'ResponseParsingError') {
+;;;                 kukit.E = 'Response parsing error: ' + e;
+                    this.processError(kukit.E);
+                } else if (e.name == 'ExplicitError') {
+                    this.processError(e.errorcommand);
 ;;;             } else {
-;;;                 var msg = 'Unhandled error during command execution: ' + e;
-;;;                 kukit.logError(msg);
+;;;                 kukit.E = 'Unhandled error during command execution: ' + e;
+;;;                 kukit.logError(kukit.E);
 ;;;                 // also IE acts foul on thrown errors
 ;;;                 // but at least mumbles something
+;;;                 // XXX TODO We should also signal the problem to the user
+;;;                 // in production mode, in this case, see the other comment
+;;;                 // in this file.
 ;;;                 throw e;
-;;;             }
-;;;         }
+                }
+            }
         }
     }
 };
@@ -159,9 +166,8 @@
             try {
                 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;
+;;;             kukit.E = 'Error parsing X-KSSCOMMANDS header.';
+                throw new kukit.err.ResponseParsingError(msg);
             }
             commandstags = kukit.dom.getNsTags(dom, 'commands');
             if (commandstags.length != 1) {
@@ -174,21 +180,19 @@
             // and log it as reported from the dom
             // Opera <= 8.5 does not have the parseError attribute,
             // so check for it first
-            dom = domDoc.responseXML;
-;;;         var msg = 'Unknown server error (invalid KSS response, no error';
-;;;         msg += ' info received)';
+;;;         dom = domDoc.responseXML;
+;;;         kukit.E = 'Unknown server error (invalid KSS response, no error';
+;;;         kukit.E += ' info received)';
 ;;;         if (dom && dom.parseError && (dom.parseError != 0)) {
-;;;             msg += ' : ' + Sarissa.getParseErrorText(dom);
+;;;             kukit.E += ' : ' + Sarissa.getParseErrorText(dom);
 ;;;             }
-;;;         kukit.E = new kukit.err.ResponseParsingError(msg);
-            throw kukit.E;
+            throw new kukit.err.ResponseParsingError(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;
+;;;     kukit.E = 'Neither xml nor html payload.';
+        throw new kukit.err.ResponseParsingError(msg);
     }
     // find the commands (atm we don't limit ourselves inside the commandstag)
     var commands = kukit.dom.getNsTags(dom, 'command');


More information about the Kukit-checkins mailing list