Getting Extended Exception Information

Benjamin Niemann b.niemann at betternet.de
Wed Jul 21 03:36:14 EDT 2004


Cy Edmunds wrote:
> In an exception handler I can get the error message by just converting the
> Exception to a string. How do I get the entire message including the call
> stack information that I see printed out with an uncaught exception?
> 
what you are looking for is probably:

import traceback

try:
   ...
except:
   stackdump = "".join(traceback.format_exception(sys.exc_type,
             sys.exc_value, sys.exc_traceback))
   print stackdump



More information about the Python-list mailing list