Exception catching

Since all methods can now throw sidl.RuntimeException, Babel ensures there is an out argument to hold an exception. If not explicitly specified, Babel will automatically add the argument. Using the example shown in Subsection 7.2.2, a C++ code fragment (from the regression tests) that utilizes the getFib method is$:$


#ifdef SIDL_USE_UCXX
using namespace ucxx;
#endif

/* ...lines deleted... */
ExceptionTest::Fib fib = ExceptionTest::Fib::_create();
try { 
  int result = fib.getFib( 4, 100, 32000, 0 );
  cout << "Result of fib.getFib() = " << result << endl;
} catch ( ExceptionTest::NegativeValueException  e ) { 
  // ...
} catch ( ExceptionTest::FibException e ) { 
  // ...
}
/* ...lines deleted... */

Note that SIDL exceptions map well into C++ exceptions allowing native exception mechanisms to be employed.





babel-1.4.0
users_guide Last Modified 2008-10-16

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