Fix #231: Add error handling to JS and document the API a bit better.

From the comments in the issue I figured the best fix was to actually handle the errors properly in our JS and to add an example and pointer to our JS in the docs. Let me know if you think we need more than this to consider the issue fixed.