Better handle reporting internal errors.

When something went wrong with development, it was really difficult to
see a traceback or, in some cases, to see the real error message. This
helps with that by logging unexpected exceptions and by slimming down
one of the more complicated try/except blocks.