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

Rethink error types #25

Closed
asomers opened this issue Dec 2, 2022 · 0 comments · Fixed by #32
Closed

Rethink error types #25

asomers opened this issue Dec 2, 2022 · 0 comments · Fixed by #32

Comments

@asomers
Copy link
Collaborator

asomers commented Dec 2, 2022

I find CapErr to be confusing. Every type wraps either io::Error or ffi::NulError. The variants mainly serve to tell the user which function returned the error. But the user already knows that. I propose that we use plain io::Result for all functions whose inner error type is an io::Error. And for the few functions with more complicated error types we'll make an enum for each one. That's essentially the approach we take in the Nix crate.

asomers added a commit to asomers/capsicum-rs that referenced this issue Dec 19, 2022
CapErr simply served to wrap an io::Error around an enum that mainly
just served to tell the user what function he had just called.  But the
user already knew that.  Simpler just to return io::Error directly.  The
only complication was Directory::open_file, which needs to handle a
NulError.  I mapped that to io::Error with an ErrorKind of Other.

Fixes dlrobertson#25
asomers added a commit to asomers/capsicum-rs that referenced this issue Dec 19, 2022
CapErr simply served to wrap an io::Error around an enum that mainly
just served to tell the user what function he had just called.  But the
user already knew that.  Simpler just to return io::Error directly.  The
only complication was Directory::open_file, which needs to handle a
NulError.  I mapped that to io::Error with an ErrorKind of Other.

Fixes dlrobertson#25
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

Successfully merging a pull request may close this issue.

1 participant