try
and catch
statements.
For Platforms without C++ Exception Support
Object Implementation Considerations
For Platforms without C++ Exception Support
Not all C++ compilers support exceptions through the try
and catch
statements, so the CORBA specification defines an Environment
class for reflecting exceptions. VisiBroker uses the Environment class, along with a set of macros, to provide your applications with exception handling capabilities when try
and catch
are not supported. The Exception Macros
The Environment
class is used internally by the ORB and is transparent to you as a programmer. The only requirement is that you use these exception macros to throw, try and catch exceptions. These macros will transparently manipulate the Environment
class for you if your compiler does not support exceptions.try
statement. Using the Exception Macros
You can modify the application client code shown in Catching System Exceptions to use the compatibility macros. The following example shows the modifications in bold type.
....library *library_object;
PMCTRY {
library_object = library::_bind();
}
// Check for errors
PMCCATCH(CORBA::SystemException excep) {
cout << "System Exception occurred:" << endl;
cout << "exception name: " <<
excep._name() << endl;
cout << "minor code: " <<
excep.minor() << endl;
cout << "completion code: " <<
excep.completed() << endl;
}
PMCENDCATCH
...
throw
statement is not generated.
virtual CORBA::Boolean add_book(const book& book_info);The object's implementation of
add_book
would use PMCTHROW
to raise the exception.
CORBA::Boolean Library::add_book(const book& book_info){ CORBA::Boolean ret;
if( (ret = bk_list.add_to_list(book_info)) == 0 )
PMCTHROW (library::CapacityExceeded();) return ret; }