943,715 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 312
  • C++ RSS
Sep 18th, 2009
0

API Flag Setting, is there no better way?

Expand Post »
I am writing a database API in C++ and I cant seem to think of a good way to handle the errors. For example if certain error conditions are met I would like to set some sort of error flag and allow every class to check that flag. I have the following classes

Database
Table (included in Database)
Column (included in Table)

I want to set some sort of flag in Column if an error is found and then check it on the next function call to a function of table or database. I was thinking I would create an error class as follows:
C++ Syntax (Toggle Plain Text)
  1. class Error
  2. {
  3. bool error;
  4. string message;
  5.  
  6. Error() {
  7. error = false;
  8. message = " ";
  9. }
  10.  
  11. bool isError() { return error;
  12. string getMessage() { return message; }
  13. }
An Error object would be initialized in the Database class(top level class) but to set it I would have to have return types that could somehow pass up to Database every time. Is there a way to make a flag that every class can see and access? That or is there a better way to do this that I am missing? I really don't like to waste the overhead of passing info up and down the chain.

Thanks!!
Similar Threads
Reputation Points: 39
Solved Threads: 1
Junior Poster in Training
chunalt787 is offline Offline
84 posts
since Apr 2008
Sep 18th, 2009
0

Re: API Flag Setting, is there no better way?

Use the error handling that already built in, called stdexcept
Reputation Points: 840
Solved Threads: 594
Senior Poster
firstPerson is offline Offline
3,862 posts
since Dec 2008
Sep 19th, 2009
0

Re: API Flag Setting, is there no better way?

Thanks for information, actually I was looking for this, if you want know more information about c++ static analysis keep visit this forum.
Reputation Points: 10
Solved Threads: 2
Newbie Poster
David Boon is offline Offline
8 posts
since Apr 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Problem with string to numeric conversion
Next Thread in C++ Forum Timeline: Need Help in Downloading a File from Internet using C++ or Win32 API?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC