Catch occasional exceptions - curses

Peter Hansen peter at engcorp.com
Thu Jul 29 00:37:31 CEST 2004


Thomas Lindgaard wrote:

> Hello
> 
> I'm almost done with my webcrawler with a nice curses interface. But every
> once in a while an exception is thrown and not caught, and because of the
> use of curses I can't figure out which exceptions are thrown and from
> where.
> 
> Is the a way to catch all exceptions not handled elsewhere and print them
> to my log window? IE. something like:
> 
> if __name__ == 'main':
>   try:
>     # the whole program (more or less)
>   except CatchAllExceptionsInSomeMagicWay:
>     printExceptionToLog()

try:
    #
except:
    traceback.print_exc(sys.exc_info())

Variations on that using other functions in the traceback
module are easy...



More information about the Python-list mailing list