Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #15778 > unrolled thread
| Started by | Frederic Rentsch <anthra.norell@bluewin.ch> |
|---|---|
| First post | 2011-11-16 17:57 +0100 |
| Last post | 2011-11-16 17:57 +0100 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
try - except. How to identify errors unknown in advance? Frederic Rentsch <anthra.norell@bluewin.ch> - 2011-11-16 17:57 +0100
| From | Frederic Rentsch <anthra.norell@bluewin.ch> |
|---|---|
| Date | 2011-11-16 17:57 +0100 |
| Subject | try - except. How to identify errors unknown in advance? |
| Message-ID | <mailman.2772.1321462721.27778.python-list@python.org> |
Hi all, I'd like to log MySQL errors. If I do: try: (command) except MySQLdb.OperationalError, e: print e I may get something like: (1136, "Column count doesn't match value count at row 1") If I don't know in advance which error to expect, but on the contrary want to find out which error occurred, I can catch any error by omitting the name: except: (handle) But now I don't have access to the error message 'e'. I'm sure there's a way and it's probably ridiculously simple. Frederic
Back to top | Article view | comp.lang.python
csiph-web