Переглянути джерело

Not sure it's the best error handling method but it works

Gaël Métais 11 роки тому
батько
коміт
3f3e250a49
1 змінених файлів з 15 додано та 9 видалено
  1. 15 9
      phantomas_custom/modules/jsErrYLT/jsErrYLT.js

+ 15 - 9
phantomas_custom/modules/jsErrYLT/jsErrYLT.js

@@ -29,14 +29,20 @@ exports.module = function(phantomas) {
         phantomas.incrMetric('jsErrors');
         phantomas.addOffender('jsErrors', msg + ' - ' + trace.join(' / '));
 
-        // TODO : send the error back to the browser ?
-        /*phantomas.pushContext({
-            type: 'error',
-            callDetails: {
-                arguments: [msg]
-            },
-            caller: trace[0],
-            backtrace: trace.join(' / ')
-        });*/
+        // Yeah, this is weird, i'm sending the error back to the browser...
+        phantomas.evaluate(function(msg, caller, trace) {
+            (function(phantomas) {
+
+                phantomas.pushContext({
+                    type: 'error',
+                    callDetails: {
+                        arguments: [msg]
+                    },
+                    caller: caller,
+                    backtrace: trace
+                });
+
+            })(window.__phantomas);
+        }, msg, trace[0], trace.join(' / '));
     });
 };