Skip to content
Browse files

Better failure when screenshot doesn't save

* Non-writable paths would raise JSON::ParseError
* Now a clearer error is raised
  • Loading branch information...
1 parent d787215 commit b78ba754e5537f402933364e949430386196a00d @eagletmt eagletmt committed with jferris Feb 6, 2014
Showing with 20 additions and 1 deletion.
  1. +10 −0 spec/driver_rendering_spec.rb
  2. +10 −1 src/Render.cpp
View
10 spec/driver_rendering_spec.rb
@@ -90,4 +90,14 @@ def render(options)
driver.evaluate_script('window.innerHeight').should eq 600
end
end
+
+ context "with invalid filepath" do
+ before do
+ @file_name = File.dirname(@file_name)
+ end
+
+ it "raises an InvalidResponseError" do
+ expect { render({}) }.to raise_error(Capybara::Webkit::InvalidResponseError)
+ end
+ end
end
View
11 src/Render.cpp
@@ -1,6 +1,7 @@
#include "Render.h"
#include "WebPage.h"
#include "WebPageManager.h"
+#include "ErrorMessage.h"
Render::Render(WebPageManager *manager, QStringList &arguments, QObject *parent) : SocketCommand(manager, arguments, parent) {
}
@@ -14,5 +15,13 @@ void Render::start() {
bool result = page()->render( imagePath, size );
- finish(result);
+ if (result) {
+ finish(true);
+ } else {
+ const QString failure = QString("Unable to save %1x%2 image to %3").
+ arg(width).
+ arg(height).
+ arg(imagePath);
+ finish(false, new ErrorMessage(failure));
+ }
}

0 comments on commit b78ba75

Please sign in to comment.
Something went wrong with that request. Please try again.