[WIP] Expanded scope of the try/except block in the error reporter

Waiting for Jan to explicitly approve this.
I tend to be conservative with throwing stuff out in other people's code, but you're right. Too bad that there's no reliable way to automatically clean up unused import in Python IDEs. I know that PyCharm has such a function but from what I've heard other people say it can't always be trusted.