Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Exceptions #18

Open
mtangoo opened this issue Oct 30, 2015 · 2 comments
Open

Remove Exceptions #18

mtangoo opened this issue Oct 30, 2015 · 2 comments
Assignees
Milestone

Comments

@mtangoo
Copy link
Owner

mtangoo commented Oct 30, 2015

In wxWidgets coding guidelines exceptions are discouraged. This ticket aim at removing all exceptions in the library.

The idea I have is to have a class similar to QT SQLError. For function that can return bool (like Commit) will do so and for the rest, checking the error it will be something like

wxDatabase *pDatabase =  new wxMysqlDatabase(strServer, strDatabase, strUser, strPassword);
wxSQLError *error = pDatabase->GetLastError();
if(error->GetCode() == 0)
{
    //success
}
else
{
    //unsuccesful
    error->GetText();
    error->GetCode();
}

What do you think @patlkli @manyleaves and whoever reads this ;) ?

@mtangoo mtangoo added this to the 1.0 milestone Oct 30, 2015
@mtangoo mtangoo self-assigned this Oct 30, 2015
@manyleaves
Copy link
Collaborator

You already have a class wxDatabaseErrorReporter that more or less does what you describe. My suggestion would be to rename wxDatabaseErrorReporter::ThrowDatabaseException to something like wxDatabaseErrorReporter::LogError and call wxLogError by default or maybe throw an exception within #ifdef #else #endif. Could also rename wxDatabaseErrorReporter! Also, should we complete the map for each wxXYZDatabase::TranslateErrorCode(int nCode) method or continue to pass through the native error codes?

@mtangoo
Copy link
Owner Author

mtangoo commented Nov 2, 2015

You already have a class wxDatabaseErrorReporter that more or less does what you describe. My suggestion would be to rename wxDatabaseErrorReporter::ThrowDatabaseException to something like wxDatabaseErrorReporter::LogError and call wxLogError by default or

Yeah, above suggestion is an abstract. We can reuse the wxDatabaseErrorReporter and just rename it. I have no problem with that. My concern is, user must have a way to know what error happened (code) and the message. So my question was how do we provide for this?

wxLog is okay but then when user want to do something with error (like tell user that libpq.so is missing) is forced to use logging. Some people don't use logging so they will have problem here.

maybe throw an exception within #ifdef #else #endif.

We should avoid having exceptions thrown at all ;)

Could also rename wxDatabaseErrorReporter! Also, should we complete the map for each wxXYZDatabase::TranslateErrorCode(int nCode) method or continue to pass through the native error codes?

I want to hear your opinions on that.

@patlkli what do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants