Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

For logging in C++, there are some macros to help:

Code Block
languagejavacpp
titleJava C++ Logger
ACS_TRACE("...");
ACS_DEBUG("...");
ACS_SHORT_LOG((LM_INFO, "..."));
ACS_SHORT_LOG((LM_WARNING, "..."));
ACS_SHORT_LOG((LM_ERROR, "..."));

For catching and raising exceptions:

Code Block
languagejavacpp
titleJava C++ Error Handling
//Shared
#include <<Interface>Err.h>


//For catching exceptions
//Along CORBA calls
catch(<Interface>Err::<ExceptionName>Ex &_ex) { ... }
//Internally in the server... more convenient to edit parameters or log if needed
catch(<Interface>Err::<ExceptionName>ExImpl &_ex) { ... }

//For raising exceptions
//Along CORBA calls
throw <Interface>Err::<ExceptionName>ExImpl(__FILE__, __LINE__, "<CustomMessage>").get<ExceptionName>Ex();
//Internally in the server...
throw <Interface>Err::<ExceptionNanem>ExImpl(__FILE__, __LINE__, "<CustomMessage>");

//For raising exceptions with parameters
<Interface>Err::<ExceptionName>ExImpl err(__FILE__, __LINE__, "<CustomMessage>");
err.set<ParamName>(<Value>);
throw err.get<ExceptionName>Ex();

//For logging an error message from the exceptions
<Interface>Err::<ExceptionName>ExImpl err(__FILE__, __LINE__, "<CustomMessage>");
err.log();
throw err.get<ExceptionName>Ex();

...