Adds a little error handling on the JS side