Generate javascript errors the right way

Helpful for both testing and actual work