Move error handling to a separate function

This removes a circular reference caused by saving
the traceback as a local variable. The function which
gets the traceback is not being called when the
error is raised, so it's local variables are not
referenced by the traceback.

Thanks to Tres for pointing this out:
https://github.com/Pylons/pyramid_exclog/pull/12#discussion_r2812532