WpclsSetError: Difference between revisions
Appearance
Created page with "{{DISPLAYTITLE:wpclsSetError}} This class method sets the current error code within a class object. ==Syntax== <pre> rc = _wpclsSetError(somSelf, ulErrorId); </pre> ==Parameters== ;''somSelf'' (M_WPObject *) - input :Pointer to the WPObject class object. ;''ulErrorId'' (ULONG) - input :The error code to store. ==Returns== ;''rc'' (BOOL) - returns: Success indicator. :'''TRUE''' – The error was successfully stored. :'''FALSE''' – The error was not..." |
(No difference)
|
Latest revision as of 21:57, 25 May 2025
This class method sets the current error code within a class object.
Syntax
rc = _wpclsSetError(somSelf, ulErrorId);
Parameters
- somSelf (M_WPObject *) - input
- Pointer to the WPObject class object.
- ulErrorId (ULONG) - input
- The error code to store.
Returns
- rc (BOOL) - returns
- Success indicator.
- TRUE – The error was successfully stored.
- FALSE – The error was not successfully stored.
Remarks
This method is intended for use by class methods that return BOOLEAN values. When such a method fails, it can log the associated error code using `wpclsSetError`, so that the caller may retrieve it later via wpclsQueryError. This is analogous to the `WinSetErrorInfo` function used by Presentation Manager to log error return codes.
Usage
It is recommended that this method be called **only** when a class method does **not** execute successfully.
How to Override
Never override this class method.
Example Code
This example finds all occurrences of an object type in a folder and uses `wpclsSetError` to manage error reporting.
VOID clsFindEverybody(SOMAny *self)
{
BOOL rc;
HFIND hFind = 0;
CLASS Class[2];
OBJECT Object[10];
ULONG ulCount = 10;
WPFolder *folder = 0;
ULONG errorid = 0;
CHAR sz[CCHMAXPATH];
PSZ title = sz;
Class[0] = _WPFolder;
Class[1] = NULL;
folder = _wpclsQueryFolder(_WPFolder, "<WP_DESKTOP>", TRUE);
_wpclsSetError(_WPObject, 0); // Reset error indicators
rc = _wpclsFindObjectFirst(_WPObject, Class, &hFind,
NULL, folder, TRUE, NULL,
Object, &ulCount);
errorid = _wpclsQueryError(_WPObject);
if ((!rc && (errorid == WPERR_BUFFER_OVERFLOW)) || rc) {
// Process objects found
} else {
somPrintf("_wpclsFindObjectFirst failed, errorid=%u\n", errorid);
return;
}
do {
_wpclsSetError(_WPObject, 0);
rc = _wpclsFindObjectNext(_WPObject, hFind, Object, &ulCount);
errorid = _wpclsQueryError(_WPObject);
if ((!rc && (errorid == WPERR_BUFFER_OVERFLOW)) || rc) {
// Process objects found
} else {
somPrintf("_wpclsFindObjectNext failed, errorid=%u\n", errorid);
return;
}
} while (errorid == WPERR_BUFFER_OVERFLOW);
_wpclsSetError(_WPObject, 0);
rc = _wpclsFindObjectEnd(_WPObject, hFind);
if (!rc) {
errorid = _wpclsQueryError(_WPObject);
somPrintf("_wpclsFindObjectEnd failed, errorid=%u\n", errorid);
return;
}
}