try
and catch
statements.
try
and catch
statements, so the CORBA specification defines an Environment
class for reflecting exceptions. ISB for C++ 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.
Table 11.14 The PMC exception Macros.
Using the Exception Macros
The following code example shows how to use the compatibility exception macros.
Using the compatibility macros to catch a system exception.
....
library *library_object;PMCTRY
{
library_object = library::_bind();
}
// Check for errorsPMCCATCH(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
... Object Implementation Considerations
The IDL compiler detects whether or not your C++ compiler supports exceptions and generates code accordingly. The sample code below would appear as follows for a compiler without C++ support. Note that the 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;
}
Last Updated: 02/03/98 15:34:36
Any sample code included above is provided for your use on an "AS IS" basis, under the Netscape License Agreement - Terms of Use