propapating exceptions
Quinn Dunkan
quinn at lira.ugcs.caltech.edu
Fri Jul 16 19:26:17 EDT 1999
I've lately found myself in the position of wanting to catch exceptions
based on their attributes, rather than on the exception itself. So (in
mal's odbc module):
try:
some sql command
except ODBC.MySQL.OperationalError, msg:
if msg[1] == CR_SERVER_GONE_ERROR: # (snarfed out of errmsg.h)
restart server, try again
else:
raise sys.exc_info()[0], sys.exc_info()[1]
It's a rather wordy way to pass the exception on without touching it,
and I still lose the traceback info. Is there a better way to pass on
an exception as if it had never been caught?
More information about the Python-list
mailing list