Utility class for storing temporary error information?

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 , . , . .

! .

+3
2

throw ErrorData? , .

, getSystemError (, , , ).

0

, . , , , .

, getter , . , getter :

class ErrorManager
{
    const Error& getError();
    void setError( Error& err );  // Or however you would actually set the error
}

class Widget : public ErrorManager
{
    // Implementation details
}

Widget w;
w.getError()

, , . , . -a , , . is-a ErrorManager, .

!

0

All Articles