OA&M API for Linux Programming Guide — August 2005 17
3
3.Error Handling
This chapter describes the error handling capabilities provided by the OA&M API.
When an error occurs during execution of a function in one of the System Component classes
(CCTDomain, ICTNode, ICTBoard or ICTClockAgent), an exception is thrown. Exceptions can be
caught and handled by including standard C++ try/catch blocks throughout your application code.
The following sample try/catch block catches and handles an exception that is thrown when the
application attempts to use an incorrect parameter (“128.0.0.1” instead of “127.0.0.1”) for the
CCTDomain::GetNode( ) function:
//processing....
...
//Initiate and catch DLG_INVALID_SERVER exception
try
{
cout<< "Initiating DLG_INVALID_SERVER exception:"<<endl;
//Attempt to get node from domain using incorrect default parameter. Exception thrown.
pNode = pDomain->GetNode("128.0.0.1");
}
catch (CCTDasiException e)
{
cerr<<"Exception: "<<endl;
cerr<<"Error Value: "<<hex<<e.m_dlgSysError<<endl;
cerr<<"Error String: "<<e.m_errDesc<<endl;
}
...
//continue processing
The CCTDasiException class defines the exceptions that can be thrown by the CCTDomain,
ICTNode, ICTBoard or ICTClockAgent member functions.
For a complete list of error codes that can be included in CCTDasiException objects, refer to the
OA&M API for Linux Operating Systems Library Reference.