Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!tudelft.nl!txtfeed1.tudelft.nl!feeder3.cambriumusenet.nl!feed.tweaknews.nl!193.201.147.92.MISMATCH!xlned.com!feeder5.xlned.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.070 X-Spam-Evidence: '*H*': 0.86; '*S*': 0.00; 'x-mailer:evolution 2.28.3': 0.07; 'except:': 0.16; 'frederic': 0.16; 'from:addr:anthra.norell': 0.16; 'omitting': 0.16; 'row': 0.16; 'advance': 0.17; "doesn't": 0.23; 'received:195.186': 0.23; 'received:bluewin.ch': 0.23; "i'm": 0.26; 'all,': 0.27; 'print': 0.29; 'from:addr:bluewin.ch': 0.30; 'subject:?': 0.31; 'error': 0.31; 'to:addr:python-list': 0.32; 'match': 0.33; 'probably': 0.34; 'try:': 0.34; 'subject:How': 0.35; 'something': 0.36; 'but': 0.37; 'received:192': 0.38; "i'd": 0.39; 'except': 0.39; "there's": 0.39; "it's": 0.39; 'to:addr:python.org': 0.39; 'subject:. ': 0.65; 'received:ch': 0.66; 'contrary': 0.73; 'ridiculously': 0.84; 'subject:try': 0.84 Subject: try - except. How to identify errors unknown in advance? From: Frederic Rentsch To: python-list@python.org Content-Type: text/plain; charset="UTF-8" Date: Wed, 16 Nov 2011 17:57:27 +0100 Mime-Version: 1.0 X-Mailer: Evolution 2.28.3 Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 25 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1321462721 news.xs4all.nl 6902 [2001:888:2000:d::a6]:52660 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:15778 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