Commit 8e107626 8e107626789de98e791ba5b04f3946e32e6f7578 by Nicolas Perriault

catch errors thrown in onStepComplete() hook

1 parent 6c72cc1d
...@@ -1337,13 +1337,13 @@ Casper.prototype.runStep = function runStep(step) { ...@@ -1337,13 +1337,13 @@ Casper.prototype.runStep = function runStep(step) {
1337 this.emit('step.start', step); 1337 this.emit('step.start', step);
1338 try { 1338 try {
1339 stepResult = step.call(this, this.currentResponse); 1339 stepResult = step.call(this, this.currentResponse);
1340 if (utils.isFunction(this.options.onStepComplete)) {
1341 this.options.onStepComplete.call(this, this, stepResult);
1342 }
1340 } catch (err) { 1343 } catch (err) {
1341 this.emit('step.error', err); 1344 this.emit('step.error', err);
1342 throw err; 1345 throw err;
1343 } 1346 }
1344 if (utils.isFunction(this.options.onStepComplete)) {
1345 this.options.onStepComplete.call(this, this, stepResult);
1346 }
1347 if (!skipLog) { 1347 if (!skipLog) {
1348 this.emit('step.complete', stepResult); 1348 this.emit('step.complete', stepResult);
1349 this.log(stepInfo + f(": done in %dms.", new Date().getTime() - this.startTime), "info"); 1349 this.log(stepInfo + f(": done in %dms.", new Date().getTime() - this.startTime), "info");
......