Which exception has been used? (was: Which exception to use?)
Gonçalo Rodrigues
op73418 at mail.telepac.pt
Thu Jan 30 19:10:16 EST 2003
More information about the Python-list mailing list
Thu Jan 30 19:10:16 EST 2003
- Previous message (by thread): Which exception has been used? (was: Which exception to use?)
- Next message (by thread): Which exception has been used? (was: Which exception to use?)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Thu, 30 Jan 2003 22:43:15 -0000, claird at lairds.com (Cameron Laird) wrote: [snip] >One of my problems is that I don't know how to write >"the default case". When we see the above, I assume >we all have in mind client code that looks like > try: > myfunction() > except SpecializedError, e: > something_special() > except StandardError, e: > cope_somehow_with_this(e) > >Suppose, as is always true, though, that I'm dealing >with modules not under my control. How do I catch >"other"? There must be something I'm missing about >the new type and exception systems, 'cause I don't >see a Pythonic way to write > .... > except OTHER, e: > # The foreign code threw an exception of > # a type I don't recognize, but I need > # to process/log/... 'e'. > cope(e) >Yes, I can write > .... > except: > cope() >but then I've lost the information I want in 'e'. Does this solve your problem? >>> try: ... raise TypeError("This is a whacky example!") ... except Exception, e: ... print e ... This is a whacky example! >>> Inheritance-works-with-exceptions-ly yours, G. Rodrigues
- Previous message (by thread): Which exception has been used? (was: Which exception to use?)
- Next message (by thread): Which exception has been used? (was: Which exception to use?)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list