Problem overriding sys.excepthook
Patrick Maupin
pmaupin at gmail.com
Mon Jan 2 18:50:55 EST 2006
Lunchtimemama wrote:
> What is the superior method of exception handling:
...
For a start, note that the exception hook does not _really_ have to be
in the main module, just imported before any "protected" code is to be
executed.
Having said that, what I personally typically do for exception trapping
doesn't even require an exception hook. I will execute all my code
from inside a try/except block in the main module. If the exception is
invoked, you can query and get all the data about the exception like
you are currently doing, and then re-raise the exception (or not).
I haven't given too much thought to when I would set an exception hook.
It seems like more of a debugger kind of thing. Especially if you
have control over the entire app, a try/except at the top level feels
cleaner to me.
Regards,
Pat
More information about the Python-list
mailing list