I'm working on adding end-to-end tests, which also run javascript code. The headless browser that I use will throw exceptions in the tests if an exception is thrown in the javascript. So instead of/in addition to alert(), I would like to have some throws in there as well, to make the e2e tests fail if something goes wrong in javascript land.