Improve JS exception handling.