Getting Extended Exception Information
Duncan Booth
me at privacy.net
Wed Jul 21 04:21:14 EDT 2004
Benjamin Niemann <b.niemann at betternet.de> wrote in
news:cdl694$jqu$1 at online.de:
> 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
Please note that sys.exc_type, sys.exc_value and sys.exc_traceback have
been deprecated for a long time now (they are not thread-safe). Use
sys.exc_info() instead.
More information about the Python-list
mailing list