Getting details about the last error

Almost all methods return a bool value or an object pointer reflecting the success of the operation. You should test this value. If it is "negative" (false respectively NULL) then an error occurred. To get details about the error you can use the following (property) methods:

§      GetITLogLib().GetLastErrorCode()

§      GetITLogLib().GetLastErrorDescription()

 

Here is an example code snippet:

 

BOOL CLoggingDemoVCApp::InitInstance() {

if(!GetITLogLib().Initialize("LoggingDemoVC", "LoggingDemoVC.icf",

""))

{

// - couldn’t initialize ITLogLib

 

// We show this error in a MsgBox and cause the program to exit.

// Note that it wouldn’t make sense to try to log this error

// (using ITLogLib).

MessageBox(NULL, GetITLogLib().GetLastErrorDescription(),

"Error", MB_OK);

return FALSE;

}

return TRUE;

}

 

And here is another:

 

if(!GetITLogLib().OpenLogChannel("DeveloperLog")) {

// - method returns |ITOutputLogChannel*|, but we don’t need

// this value here

 

// log this error (in the default logchannel, "StdLog")

QuickLog("LoggingDemo", "Initialize",

"Couldn’t open logchannel 'DeveloperLog'", LEVEL_ERROR);

};

 

// We continue our program, but output to DeveloperLog will get lost.