-
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
VfsError does not have an easy way to programmatically match against Error Variants #33
Comments
Thank your for the suggestion, this does indeed seem like common use case. |
If it's alright to have a breaking change, it may also make sense to change the error type to a struct that contains the type of error, along with an optional cause for it. That way |
Hi, sorry, for the late reply. I am not sure using an additional struct is really necessary. Using |
My main reasoning behind that idea is that you could do an exhaustive match over each error kind, without having to match on WithContext and repeating the match, like how my current implementation of |
I see, yeah, that sounds quite a bit more ergonomic. Looking forward to the PR! |
Hey again!
Due to the existence of the VfsError::WithContext variant, it's harder to match on a specific error type since there may be multiple nested WithContext error levels to go through. My use case for this is to ignore an error if a file is missing, but to handle all other cases as invalid situations
There is also the situation of certain implementations returning errors like NotFound via std::io::Error rather than the VfsError variants, but I believe that's an implementation specific issue
To work around this, I currently have a function called
get_root_cause
that returns the true root cause of a VfsError, which also normalizes I/O error types to their respective VfsError variantIf this fix is alright, I can make a PR for the same. But I wanted to have some discussion on how to proceed with this bug in case there were other solutions available
The text was updated successfully, but these errors were encountered: