Best Way to Handle All Exceptions
Steven D'Aprano
steven at REMOVE.THIS.cybersource.com.au
Mon Jul 13 23:27:30 EDT 2009
On Tue, 14 Jul 2009 10:09:06 +1000, Ben Finney wrote:
> Instead of catching *all* exceptions at a specific point in your code,
> and then having nothing to do but end the program (possibly after some
> pre-exit action like logging), I think you would be better served by
> installing a custom top-level exception handler.
...
> Any other exceptions that you don't specifically catch will then go
> through to your default handle-it-just-before-we-exit ‘sys.excepthook’
> exception handler.
Isn't that risky though? Won't that potentially change the exception-
handling behaviour of functions and classes he imports from other modules?
--
Steven
More information about the Python-list
mailing list