howto catch an Exception and still print the TraceBack?

Fabio Zadrozny fabioz at esss.com.br
Wed Feb 1 10:57:26 EST 2006


I find the following very good for most needs:

try:
    raise RuntimeError('err')
except:
    import traceback;traceback.print_exc()

-- if you use Pydev, there's a template for that called printexc.

Cheers,

Fabio

Saizan wrote:

>In an event-driven application i'd like to keep the program alive regardless of any exceptions raised by the handlers,
>but still be able to debug them by reading the appropriate TraceBack from stderr.
>I can put something like:
>
>try:
>	self.call_handler(handler,*args)
>except Exception, e:
>	print e
>	print e.args
>
>in the dispatcher, but that isn't as helpful as a complete TraceBack.
>  
>





More information about the Python-list mailing list