[Tutor] using sys.excepthook to handled unhandled exceptions

Alan Gauld alan.gauld at btinternet.com
Thu Aug 28 01:51:35 CEST 2008


"Tony Cappellini" <cappy2112 at gmail.com> wrote

> With that in mind, I thought I would add a handler which logs the 
> tracebacks
> to a file, display a 1-line message about the error on the screen, 
> so the
> user has some
> idea of what happened, along with a simple message like this

I tend to do that after I get everything working by just wrapping
main() in a try/except clause that catches everything then mapping
any errors to friendly strings and logging the traceback if logging
is enabled.

In other words I don't mess with the excepthook value.

HTH,

-- 
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld 




More information about the Tutor mailing list