-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Errors in the API #23
Comments
I see that there is a way to get errors when using |
log.Fatals only happen when Badger itself causes issues. External input won't cause it. In fact, these Fatals are really great at catching bugs and making the library robust. We send errors back when justified, for e.g. when doing CAS operations. |
badger.NewKV("non-existent-dir/foo") crashes my program. That's not acceptable. Opening a non-existent file is not an internal error, it's a user error which my program will want to relay to the user in an arbitrary way. |
Any operation that could fail, under any conditions, should return an error.
Sure, you can hope the user provides a writeable directory, but the fact remains that if they give you a directory, and you can't write to it, you need to tell them they failed on their end of the contract. |
I see your point, you are right. We can do much better error handling. |
Besides the pragmatic concerns, it violates go conventions to panic across a package boundary. |
Yup. Agree with all the concerns here. We have started to surface errors via the API calls (see 31c0bd2). We'll do a sweep over the next couple of weeks over the entire code base. And try to remove all calls to y.Checkf, if possible. The biggest hurdle would be to deal with background tasks, and we'll need to build mechanisms to deal graciously with them. I'll keep you updated on this thread. |
Good to hear, looking forward to using the library. |
Excellent. I will probably switch our usage of BoltDB to Badger, since we are in the early stages of our project as well. |
I'm trying badger as a replacement for github.com/syndtr/goleveldb and one thing that hit me immediately is that there are no errors in the badger Go API. Any error will just exit the process through
log.Fatalf
. Is that a design decision or just temporary?The text was updated successfully, but these errors were encountered: