Download Sapera LT User`s Manual
Transcript
Error Management Error reporting Most Sapera++ methods return a Boolean TRUE/FALSE result to indicate success or failure. However, the actual errors conditions are still reported as soon as they happen, using one of five predefined reporting modes: • Error messages are sent to a popup window (the default) • Error messages are sent to the DALSA Log Viewer • Error messages are sent to the active debugger if any • Error messages are generated internally • Error messages are sent to the application through a callback function Use the SapManager::SetDisplayStatusMode method to set the current reporting mode, as follows: // Send error messages to the Log Viewer SapManager::SetDisplayStatusMode(SapManager::StatusLog); // Send error messages to the debugger SapManager::SetDisplayStatusMode(SapManager::StatusDebug); // Simply generate error messages SapManager::SetDisplayStatusMode(SapManager::StatusCustom); // Send errors to application using a callback function SapManager::SetDisplayStatusMode(SapManager::StatusCallback); // Restore default reporting mode SapManager::SetDisplayStatusMode(SapManager::StatusNotify); Monitoring Errors No matter which reporting mode is currently active, it is always possible to retrieve the latest error message. If the error happened when Sapera++ called a Standard API function, then a related numeric code is also available. In order the retrieve this information, call the SapManager::GetLastStatus method as follows: // Get the latest error message char errorDescr[256]; strcpy(errorDescr, SapManager::GetLastStatus()); // Get the latest error code // See the Sapera Basic Modules Reference Manual for details SAPSTATUS lastError; SapManager::GetLastStatus(&lastError); In addition, the DALSA Log Viewer utility program, included with Sapera LT, provides an easy way to view error messages. It includes a list box that stores these messages as soon as the errors happen. Available options allow you to modify the different fields for display. 42 • Introducing the Sapera LT API Sapera LT User's Manual