-
Notifications
You must be signed in to change notification settings - Fork 43
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
Reexport nix::Errno #108
Reexport nix::Errno #108
Conversation
This is useful because the Error enum in its ApiError error variant exports that type, so in order to match on the error value it's necessary to use the same version of `nix` as this crate uses. The idiom in this case is to reexport `nix` (or reexporting `Errno` would likely be fine as well, but I'm not sure if `nix` leaks in other ways maybe so I propose exporting the entire `nix` to be sure that it's correct.)
Hello, thank you for bringing this up. I'm not fond of |
Thanks for your quick answer. It doesn't look like that would be better: it's useful to be able to match on the error code (which is specifically what I'm using Why do you not like reexports? |
Hi, @Ten0, thanks for your explanation of motivation. I think it's a failure to expose these error types directly. I wish we could use Given that our API currently works this way, it might be fine to re-export |
Thanks. 😊
I agree that in an ideal world the Rust API wouldn't expose those, as they are hard to catch by users because they have to work out what each means. Errors such as However it seems difficult to be exhaustive on the ApiError variant: librados C api's error codes are undocumented, so the only way to know what error would occur in what scenario would be to test each of them manually, which seems like a very tedious task at this point, and we wouldn't even have the guarantee that the same error code is used for similar semantic meanings across C functions. However it's also true that reexporting the whole of |
So I've checked and actually the only use of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @Ten0 for this!
This is useful because the Error enum in its ApiError error variant exports that type, so in order to match on the error value it's necessary to use the same version of
nix
as this crate uses.The idiom in this case is to reexport
nix
(or reexportingErrno
would likely be fine as well, but I'm not sure ifnix
leaks in other ways maybe so I propose exporting the entirenix
to be sure that it's correct.)