Exception Handling and Inheritance
Franz GEIGER
fgeiger at datec.at
Sat Dec 23 04:45:57 EST 2000
I'd like to specialize Exceptions. So I derived a TException from Exception
and added all the things I think I need to have.
But now there is a problem: I have created a second branch in the
inheritance tree:
Exception
StandardError
IOError
...
TException
TDataException
...
When I want to catch TExceptions I write
try:
obj.meth(anyStuff)
except TException, e:
print >> sys.stderr, "Panic: %s!" % e.Formatted()
But what about Exceptions? They are not caught by my TException handler! And
Exception does not have my Formatted method.
Do I really have to catch them in a 2nd handler? Or can I add some
functionality somehow to Exception instead of implementing it in a derived
TException?
Many thanks in advance and best regards
Franz GEIGER
More information about the Python-list
mailing list