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