add JS Errors to Exception Reporting
authorCornelius Weiß <c.weiss@metaways.de>
Thu, 6 Jul 2017 07:20:04 +0000 (09:20 +0200)
committerCornelius Weiss <c.weiss@metaways.de>
Thu, 6 Jul 2017 07:17:31 +0000 (09:17 +0200)
Change-Id: Ide14dd0be6430ce0bc126cb0d9554cb016e9142f
Reviewed-on: http://gerrit.tine20.com/customers/5034
Reviewed-by: Cornelius Weiss <c.weiss@metaways.de>
Tested-by: Cornelius Weiss <c.weiss@metaways.de>
tine20/Tinebase/js/ExceptionDialog.js
tine20/Tinebase/js/ExceptionHandler.js

index 2194566..8cfb3c1 100644 (file)
@@ -58,7 +58,17 @@ Tine.Tinebase.ExceptionDialog = Ext.extend(Ext.Window, {
             
             this.exception.traceHTML = trace;
         }
-        
+
+        if (Ext.isString(this.exception.trace)) {
+            this.exception.traceHTML = Ext.util.Format.nl2br(
+                Ext.util.Format.htmlEncode(
+                    this.exception.trace
+                )
+                .replace(/ /g, '&nbsp;')
+                .replace(/\t/g, '&nbsp;&nbsp;&nbsp;&nbsp;')
+            );
+        }
+
         this.title = i18n._('Abnormal End');
         this.items = this.getReportForm();
         
index 5704d12..2748bdf 100644 (file)
@@ -75,7 +75,8 @@ Tine.Tinebase.ExceptionHandler = function() {
             code       : 'unknown',
             description: 'unknown',
             url        : 'unknown',
-            line       : 'unknown'
+            line       : 'unknown',
+            trace      : 'unknown'
         };
         
         // NOTE: Arguments is not always a real Array
@@ -89,7 +90,8 @@ Tine.Tinebase.ExceptionHandler = function() {
             error.message     = args[0].message;
             error.code        = args[0].number & 0xFFFF; //Apply binary arithmetic for IE number, firefox returns message string in element array element 0
             error.description = args[0].description;
-            
+            error.trace       = args[0].stack;
+
         } else if ((args.length == 3) && (typeof(args[2]) == "number")) { // Check the signature for a match with an unhandled exception
             error.name    = 'catchable exception';
             error.message = args[0];
@@ -330,13 +332,25 @@ Tine.Tinebase.ExceptionHandler = function() {
             Tine.Tinebase.exceptionDlg.show();
         }
     };
-    
+
+    var handleException = function(exception) {
+        exception = getNormalisedError(exception);
+
+        // for the fast :-)
+        Ext.applyIf(exception, {
+            code: -1000
+            // appName: this.app.appName,
+        });
+        handleRequestException(exception);
+    };
+
     // init window error handler
     window.onerror = window.onerror && Ext.isFunction(window.onerror) && Ext.isFunction(window.onerror.createSequence) ?
         window.onerror.createSequence(onWindowError) :
         onWindowError;
 
     return {
+        handleException: handleException,
         handleRequestException: handleRequestException
     };
 }();