|
@@ -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;
|