General default exception handler

Steve Holden sholden at holdenweb.com
Mon Dec 4 08:25:24 EST 2000


Dale Strickland-Clark <dale at out-think.NOSPAMco.uk> wrote in message
news:lj0n2to9vs8bmv3oo49mqgoc6h7esh8t37 at 4ax.com...
> 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.
>
> Thanks
> --
> Dale Strickland-Clark
> Out-Think Ltd
> Business Technology Consultants
>
If you're prepared to accept URLs which use an extended path to indicate
arguments, one poosibility is to direct all requests to a "framework page"
which then calls the required Python functionality and traps any errors it
raises.

See, for example,

    http://www.webtechniques.com/archives/1998/02/kuchling/

in which Andrew Kuchling describes the basic technique.  This seems to give
you what you want.

regards
 Steve






More information about the Python-list mailing list