In my code I have a method for logging exceptions that expects as an argument the instance of the exception that was thrown (so it can use str(exception) and traceback.format_exc(exception)). Now I want to call this method from within the __exit__ call of a context manager, but here I only have the type and value of the exception as well as the traceback. My question is, is there some way to get the raw exception that was caught by the __exit__ call or at least create a new one that I can then pass to my logging method? Continue reading...