Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5958559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:33:37+00:00 2026-05-22T18:33:37+00:00

I have been writing a light-weight framework to wrap the Windows API for personal

  • 0

I have been writing a light-weight framework to wrap the Windows API for personal projects and some fun. What I think is a good design method is that each class in the framework manages its own error information whenever something goes wrong. I have a simple error class like so:

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);
};

What I’m stuck on is how to incorporate this class into the other classes. Inheritance sounds wrong because a dialog class is not an Error class. Composition sounds better, a dialog class can have an Error class. But then I’m stuck writing a getter function for every class to retrieve the Error class’s information. Although that would only take a short time to write, there has got to be a better design method. I would rather not have to copy and paste those functions in every class either.

Any ideas would be appreciated!
Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T18:33:38+00:00Added an answer on May 22, 2026 at 6:33 pm

    Have you considered using exceptions and throwing your ErrorData class instead? That seems better than either inheritance or composition.

    It almost looks like getSystemError should be a namespace free-function instead of a member (it looks like everything it needs is passed into its parameters).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been writing some code that creates a generic blog. Its features are
I have been writing a GUI application for rsync on Windows and I have
I have been writing some C# code for a training exercise, in which I
I have been writing some Web services to be used by a few different
I have been writing some code that detects add and removal of USB devices,
I have been writing some code with basically this structure namespace util { void
I have been writing Node.js apps for quite some time now, and I have
I have been writing and debugging a minifilter on Windows 7 using the IFS
I have been writing some queries about SQL Server in order to learn. I
I have been writing C++ Console/CMD-line applications for about a year now and would

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.