Author: reebalazs
Date: Wed Aug 29 10:39:47 2007
New Revision: 46128
Modified:
kukit/kukit.js/trunk/kukit/errors.js
Log:
Fix errors properly, now works on FF + IE + Safari
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 10:39:47 2007
@@ -44,21 +44,52 @@
*
*/
+;;; var ErrorAnnotation = function() {
+;;;
+;;; this.constructError = function(e, name, message, info) {
+;;; if (typeof(info) == "undefined") {
+;;; info = {};
+;;; }
+;;; this.info = info;
+;;; this.message = name + ': ' + message;
+;;; if (typeof(e) == "undefined") {
+;;; e = new Error(this.message);
+;;; } else if (typeof(e) == "string") {
+;;; kukit.E = 'Do not raise string exceptions, as we cannot ';
+;;; kukit.E += 'annotate them properly. Use: throw new
Error(msg);';
+;;; e = new Error(e);
+;;; }
+;;; this.previous_info = e.info;
+;;; e.name = name;
+;;; e.info = this;
+;;; var fullMessage = message + ' [' + e.message + ']';
+;;; // for FF, and Safari:
+;;; e.message = fullMessage;
+;;; // for IE, message is ignored, description is used.
+;;; e.description = fullMessage;
+;;; return e;
+;;; };
+;;;
+;;; this._logRecursive = function() {
+;;; kukit.logError(this.message);
+;;; if (this.previous_info) {
+;;; this.previous_info._logRecursive();
+;;; }
+;;; };
+;;;
+;;; this.log = function() {
+;;; // This is for debugging only, normal error handling
+;;; // does not use it.
+;;; kukit.logFatal('KSS error, stack information follows:');
+;;; this._logRecursive();
+;;; };
+;;; };
+
;;; var setErrorInfo = function(e, name, message, info) {
-;;; if (typeof(info) == "undefined"){
-;;; info = {};
-;;; }
-;;; info.message = name + ': ' + message;
-;;; if (typeof(e) == "undefined") {
-;;; e = new Error(info.message);
-;;; }
-;;; info.previous_info = e.info;
-;;; e.name = name;
-;;; e.info = info;
-;;; kukit.logError(info.message);
-;;; return e;
+;;; return new ErrorAnnotation().constructError(e, name, message, info);
;;; };
+/* Protects a function */
;;; this.ExplicitError = function(errorcommand){
;;; var info = {'errorcommand':errorcommand};
@@ -99,7 +130,7 @@
/* Exceptions that re-throw (annotate) an already caught error */
;;; this.CommandExecutionError = function(e, command){
-;;; var message = 'Command [' + command.name + '] ' + e.toString();
+;;; var message = 'Command [' + command.name + '] failed';
;;; return setErrorInfo(e, 'CommandExecutionError', message);
;;; };
_______________________________________________
Kukit-checkins mailing list
[email protected]
http://codespeak.net/mailman/listinfo/kukit-checkins