Commit 063ddf76 063ddf76b6d057cad22ad094dd9a281626deb32f by Nicolas Perriault

fixed erroneous error handling in Casper.capture()

1 parent 427c643f
......@@ -143,6 +143,7 @@
*/
capture: function(targetFile, clipRect) {
var previousClipRect;
targetFile = require('fs').absolute(targetFile);
if (clipRect) {
if (!isType(clipRect, "object")) {
throw new Error("clipRect must be an Object instance.");
......@@ -153,10 +154,8 @@
} else {
this.log('Capturing page to ' + targetFile, "debug");
}
try {
this.page.render(targetFile);
} catch (e) {
this.log('Failed to capture screenshot as ' + targetFile + ': ' + e, "error");
if (!this.page.render(targetFile)) {
this.log('Failed to save screenshot to ' + targetFile + '; please check permissions', "error");
}
if (previousClipRect) {
this.page.clipRect = previousClipRect;
......