Catching a traceback
Isaac To
kkto at csis.hku.hk
Mon Jun 7 22:13:45 EDT 2004
>>>>> "Peter" == Peter Hansen <peter at engcorp.com> writes:
Peter> EAS wrote:
>> I'm wondering if there is any way to keep a program running when it
>> runs into an error (using the 'try' structure) and print the
>> traceback to the screen?
Peter> You can, of course, catch any exception at any level and print
Peter> tracebacks. In fact, if this is really what you were focusing
Peter> on, then the answer to your question might be "yes". If you can
Peter> write the code so that it does catch an exception at the right
Peter> place to allow safe continuation, then you can certainly keep
Peter> your program running, and many people use exceptions in exactly
Peter> that way.
I think the OP's query is mainly about whether it is possible to print a
stack trace without crashing the whole program.
Regards,
Isaac.
More information about the Python-list
mailing list