diff --git a/lib/tools/phantomas/custom_modules/core/scopeYLT/scopeYLT.js b/lib/tools/phantomas/custom_modules/core/scopeYLT/scopeYLT.js index 5bd80bc..b4a97e9 100644 --- a/lib/tools/phantomas/custom_modules/core/scopeYLT/scopeYLT.js +++ b/lib/tools/phantomas/custom_modules/core/scopeYLT/scopeYLT.js @@ -46,6 +46,7 @@ exports.module = function(phantomas) { obj[fn] = function() { var result; + var err; // Before if (enabled) { @@ -54,16 +55,29 @@ exports.module = function(phantomas) { // Execute try { + result = origFn.apply(this, arguments); + } 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(arguments); + + err = e; + } finally { // After if (enabled && callbackAfter) { callbackAfter.call(this, result, arguments); } + + if (err) { + phantomas.log('Re-throwing the error'); + throw err; + } } return result;