class based exceptions

Bruce Edge bedge at troikanetworks.com
Tue Apr 24 10:55:36 EDT 2001


Can one associate an exception handler with all member functions of a
class without explicitly coding it in every member?

My reasoning for this is that I have some CORBA wrapper classes. If any
member fails with a omniORB.CORBA.COMM_FAILURE exception, I need to
re-resolve the reference. Currently, I have to put an except statement in
every method, and the code to execute is the same in all cases.

eg:

class wrap:
  def __init__(self):
    self.resolve()

  def resolve(self)
    #resolve corba reference

  def read(self)
    try:
      corba.read...
    except omniORB.CORBA.COMM_FAILURE
      self.resolve()
      # retry


  def write(self)
    try:
      corba.write...
    except omniORB.CORBA.COMM_FAILURE
      self.resolve()
      # retry



More information about the Python-list mailing list