How to except the unexpected?
Sat Mar 4 06:10:22 CET 2006
Steven D'Aprano <steve at REMOVETHIScyber.com.au> writes:
> except ExpectedErrors:
> except ErrorsThatCantHappen:
> print "Congratulations! You have found a program bug!"
> print "For a $327.68 reward, please send the following " \
> "traceback to Professor Donald Knuth."
> print "An unexpected error occurred."
> print "This probably means the Internet is broken."
But this isn't good, it catches asynchronous exceptions like the user
hitting ctrl-C, which you might want to handle elsewhere. What you
want is a way to catch only actual exceptions raised from inside the
More information about the Python-list