Added JS error handling
Merge pull request #4 from tomdepplito/cleanup

Added JS error handling