I wrote a lightweight framework to wrap the Windows API for personal projects and have some fun. I believe that a good design method is that each class within the framework manages its own error information whenever something goes wrong. I have such a simple error class:
class Error
{
public:
struct ErrorData
{
DWORD sysErrCode;
tstring sysErrStr;
SYSTEMTIME localTime;
tstring errMsg;
tstring funcCall;
tstring parentClass;
};
void getErrorData(ErrorData *pErrorData);
Error(const tstring parentClass);
void setErrorData(const tstring errMsg, const tstring funcCall, const bool getSysErr = false);
private:
ErrorData errorData;
void getSystemError(DWORD &sysErrCode, tstring &sysErrStr);
};
, . , Error. , Error. getter , . , . .
!
.