propapating exceptions
Michael P. Reilly
arcege at shore.net
Fri Jul 16 21:19:57 EDT 1999
More information about the Python-list mailing list
Fri Jul 16 21:19:57 EDT 1999
- Previous message (by thread): Calling C code from Python
- Next message (by thread): propapating exceptions
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Quinn Dunkan <quinn at lira.ugcs.caltech.edu> wrote: : 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? In Python 1.5, using "raise" by itself will reissue the exception with the same value. Fortunately (or unfortunately), the traceback does not seem to be modified. -Arcege
- Previous message (by thread): Calling C code from Python
- Next message (by thread): propapating exceptions
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list