General default exception handler

Mark Hammond MarkH at
Tue Dec 5 05:59:55 CET 2000

Dale Strickland-Clark wrote:

> We have a substantial set of COM objects in Python that run a Web site.
> Currently, if an exception is raised, the user gets an unfriendly message in their browser and we
> may never know about it.
> I want to log all unhandled exceptions but I'd rather not have to put a try/except block around
> every entry point - because there are dozens of them.
> Is there a general way to catch all unhandled exceptions so I can log them and pass back something
> nice and soothing to the user?
> I'm planning to use the traceback module to record the exception info.

The only built in way is to use a "dispatcher".  The existing "debug 
dispatcher" is what "debug mode" uses to log the traceback to the 
win32traceutil module.  You can write your own dispatcher to handle 
errors any way you like.

You can set the default dispatcher by setting a _reg_dispatcher_ (or 
something like that) on the class.


More information about the Python-list mailing list