How to catch a generic exception?
Peter Maas
fpetermaas at netscape.net
Thu Mar 4 11:00:37 EST 2004
Boogie El Aceitoso schrieb:
> How can I catch a generic exception (without knowing a priori what exception
> it will be)?
>
> For example, something like this
> try:
> generateSomeException()
> except e:
> print e
did you mean catch or throw?
--- catch:
try:
generateSomeException()
except Exception, e: # Mother of all exceptions
print e
--- throw:
try:
raise Exception, "Something is rotten in the state of Denmark"
except e:
print e
--
Mit freundlichen Gruessen,
Peter Maas
--
-------------------------------------------------------------------
Peter Maas, M+R Infosysteme, D-52070 Aachen, Hubert-Wienen-Str. 24
Tel +49-241-93878-0 Fax +49-241-93878-20 eMail peter.maas at mplusr.de
-------------------------------------------------------------------
More information about the Python-list
mailing list