Wrap JS in try/catch/throw

This is to attempt to fix (fixed #1354) but I've noticed it doesn't always work. But then, *sometimes* is better than not at all.