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

Use more meaningful error messages #9

Open
Silverhorn27 opened this issue Dec 1, 2021 · 1 comment
Open

Use more meaningful error messages #9

Silverhorn27 opened this issue Dec 1, 2021 · 1 comment

Comments

@Silverhorn27
Copy link
Contributor

This crate has a poor error handling because if C library returns null pointer or code < 0 it just uses the last io error. The problem is that user can't realize where and why he got, for example, error No such file or directory (os error 2). It's great that after merge #7 we will get at least poor error handling, but any way we should add meaningful error messages because we know where this error is possible.

How I see it, at now that's c_result function which checks result value and return back the Ok(..) or Err(..), we can add one more parameter there to use additional context (look at anyhow crate).

@Silverhorn27 Silverhorn27 mentioned this issue Dec 1, 2021
@cholcombe973
Copy link
Owner

I agree the no such file or directory error is difficult for users to debug. I've run into this a number of times. I do like how anyhow adds additional context to the errors to make it easier to figure out what broke.

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

2 participants