add global window.onerror handler

This pull request fixes #170 and it fixes #190.

Unfortunately this method does not provide a full stacktrace for now (which is only visible in the JavaScript console).
However, it opens a debugger to show the JavaScript error to the user.