Exception catching

SIDL exceptions are caught very much like normal Python exceptions except the Python exception class of the SIDL type must be used. The exception value holds the SIDL object as attribute exception. Below is an example of catching exceptions from a call to getFib.


  try:
    fib.getFib(-1, 10, 10, 0)
  except ExceptionTest.NegativeValueException._Exception:
    (etype, eobj, etb) = sys.exc_info()
    # eobj is the SIDL exception object
    print eobj.exception.getNote()  # show the exception comment
    print eobj.exception.getTrace() # and traceback

Note that eobj.exception is an instance of ExceptionTest.NegativeValueException.NegativeValueException, the Python type corresponding to the SIDL type ExceptionTest.NegativeValueException.





babel-1.4.0
users_guide Last Modified 2008-10-16

http://www.llnl.gov/CASC/components
components@llnl.gov