try
and catch
statements.For Platforms without C++ Exception Support
Object Implementation Considerations
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.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.
Use this as you would use the try
statement.
Throws the specified exception.
Used to re-throw the specified exception. Used only in an event handler or in a method called by an event handler.
PMCCATCH(type_name, variable_name)
Use this to catch an exception of the specified type.
If several exceptions are to be specified for a PMCTRY block, use PMCCATCH for the first catch statement and PMCAND_CATCH for all subsequent catch statements.
Used to terminate a PMCTRY block.
....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();)