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

Inconsistency in error codes vs exceptions #65

Open
eugene-kulak opened this issue Apr 28, 2020 · 3 comments
Open

Inconsistency in error codes vs exceptions #65

eugene-kulak opened this issue Apr 28, 2020 · 3 comments

Comments

@eugene-kulak
Copy link

It is not clear why query throws an exception in case of error, but command not, so the user has to manually check the return code.

@iwongu
Copy link
Owner

iwongu commented May 16, 2020

Sorry for the late response. Which places are you mentioning? I tried to use error codes everywhere except for the methods that cannot have return values such as constructor.

@eugene-kulak
Copy link
Author

@iwongu for example command.execute you need to check return code.
It is weird to see both, and I think worth to mention in examples (I didn't know that my commands not working)

@snej
Copy link

snej commented Nov 18, 2021

I agree, it's very inconsistent. It's OK to have an API that doesn't use exceptions, but it should not use them at all, even for constructors. (Yes, that makes constructors awkward and a lot less useful. That's the price you pay for not using exceptions!)

Having some of the API return errors and some throw exceptions is kind of the worst of both worlds. Projects that don't allow exceptions can't use the library, and projects that do use exceptions now have to add a bunch of if (err) throw... gunk around most of the calls, or else if they forget to do so they'll silently miss an error.

My vote would be to change the entire API to consistently use exceptions.

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

No branches or pull requests

3 participants