Просмотр исходного кода

Spyed functions will now re-throw errors. Watchup...

Gaël Métais 10 лет назад
Родитель
Сommit
909ffc1aac
1 измененных файлов с 14 добавлено и 0 удалено
  1. 14 0
      lib/tools/phantomas/custom_modules/core/scopeYLT/scopeYLT.js

+ 14 - 0
lib/tools/phantomas/custom_modules/core/scopeYLT/scopeYLT.js

@@ -46,6 +46,7 @@ exports.module = function(phantomas) {
 
 
                         obj[fn] = function() {
                         obj[fn] = function() {
                             var result;
                             var result;
+                            var err;
                             
                             
                             // Before
                             // Before
                             if (enabled) {
                             if (enabled) {
@@ -54,16 +55,29 @@ exports.module = function(phantomas) {
 
 
                             // Execute
                             // Execute
                             try {
                             try {
+
                                 result = origFn.apply(this, arguments);
                                 result = origFn.apply(this, arguments);
+
                             } catch(e) {
                             } catch(e) {
+
+                                // Catching the err for the moment, because we need to make sure the callbackAfter function is called.
+
                                 phantomas.log('Error catched on spyed function "' + fn + '": ' + e);
                                 phantomas.log('Error catched on spyed function "' + fn + '": ' + e);
                                 phantomas.log(arguments);
                                 phantomas.log(arguments);
+
+                                err = e;
+
                             } finally {
                             } finally {
 
 
                                 // After
                                 // After
                                 if (enabled && callbackAfter) {
                                 if (enabled && callbackAfter) {
                                     callbackAfter.call(this, result, arguments);
                                     callbackAfter.call(this, result, arguments);
                                 }
                                 }
+
+                                if (err) {
+                                    phantomas.log('Re-throwing the error');
+                                    throw err;
+                                }
                             }
                             }
 
 
                             return result;
                             return result;