How to catch a generic exception?

Denis S. Otkidach ods at strana.ru
Thu Mar 4 11:57:44 EST 2004


On Thu, 4 Mar 2004, Boogie El Aceitoso wrote:

BEA> How can I catch a generic exception (without knowing a
BEA> priori what exception
BEA> it will be)?

try:
    generateSomeException()
except:
    import sys
    print sys.exc_info()[1]

BEA> For example, something like this
BEA> try:
BEA>    generateSomeException()
BEA> except e:
BEA>   print e

-- 
Denis S. Otkidach
http://www.python.ru/      [ru]





More information about the Python-list mailing list