brenden / node-webshot

Easy website screenshots in Node.js
2.12k stars 286 forks source link

Emit error from PhantomJS script to stream #118

Closed mwynholds closed 8 years ago

mwynholds commented 8 years ago

There is only one error that gets written in webshot.phantom.js at the moment, but there is no way for client code to handle or see that error. With this PR, that error would get emitted to the stream so that client code can handle it appropriately.

brenden commented 8 years ago

This looks useful to me. There definitely should be a way to expose errors from phantomjs to the nodejs side. However, the existing behavior has been to ignore all JS errors on the page and this PR would break that. Also there are cases where you might want to take a screenshot of a page even if there are errors present on the page.

So to avoid breaking existing code I've merge these commits but added an errorIfJSException option to toggle on and off this behavior. Take a look at 37998c3f8dcfedd5b5e68ba405be04eade578682 and let me know what you think.