0

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:

class Error
{
	bool error;
	string message;

	Error() {
		error = false;
		message = " ";
	}

	bool isError() { return error;
	string getMessage() { return message; }
}

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!!

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by David Boon
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.