[Tutor] catching any exception?

Chermside, Michael mchermside@ingdirect.com
Fri Nov 15 11:29:01 2002


> Apparently although "Exception" is the parent of all=20
> exceptions, it is not an exception itself, so this never matched.

Actually, I don't think that's true. Let me run a quick test:


ActivePython 2.2.1 Build 222 (ActiveState Corp.) based on
Python 2.2.1 (#34, Apr 15 2002, 09:51:39) [MSC 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> try:
...     raise Exception
... except Exception, thisException:
...     print 'Got exception %s' % Exception
...
Got exception exceptions.Exception
>>> try:
...     raise Exception
... except Exception, thisException:
...     print 'Got exception %s' % Exception
...     raise Exception(thisException, 'sql message')
...
Got exception exceptions.Exception
Traceback (most recent call last):
  File "<stdin>", line 5, in ?
Exception: (<exceptions.Exception instance at 0x00766508>, 'sql =
message')



Okay... it appears that the code you posted DOES work. Perhaps
the problem isn't where you think it is? At any rate, Exception
*is* an exception, and CAN be caught by a normal except clause.

-- Michael Chermside