-
Notifications
You must be signed in to change notification settings - Fork 291
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
Expose error kind enum for matching? #188
Comments
I don't think we would expose the If you had access to the |
Hmm. I think that since individual functions appear to each implement their own error kinds (and those structs are public) I can properly map them. However, I'm currently implementing both a https://github.com/kbacha/stellar-sdk/pull/39/files#diff-045ef8f78ba0431706a905bb35c78758R56 This enables me to map specifically for invalid errors but also catch-all when a builder replies with the generic error. Perhaps it works out the box anyhow? |
You could change from using the builders to doing the conversions yourself, thus knowing exactly what operation the error came from. |
Ah, that could work. And that's what I'm doing with the URI in this case. |
Is this issue resolved? |
I find myself with the same question @kbacha had, but I don't understand the solution @seanmonstar offered. I too am new to Rust, which may be the issue. I'm trying to upgrade a library from hyper 0.10 to hyper 0.12. The library has a domain-specific What's the best way to accomplish that? |
Now that we have |
MSRV is currently called out as 1.49, so this should be possible at this point. Could this issue be reopened? edit: #382 is open, that's probably a better place I think this would just be:
This should be a nonbreaking change IIUC. The debug impl could be adjusted or changed to a derive as well. |
Please re-open this issue, to expose uri:InvalidUri(ErrorKind). We should now be able to use the non exhaustive annotation. It should be non-breaking because the previous API was private. My use case is: I am trying to port the reqwest proxy implementation for hyper, and switch it to use uri instead of url, and there are tons of test cases that check the kind of error. |
Currently, the inner kind of the error type is unexposed which makes mapping into an SDKs error types.
https://github.com/hyperium/http/blob/master/src/error.rs#L25-L35
This works well for displaying the description but if I want to map the result to a different error to make it consistent I cannot. For example, if I'm using both
hyper
andhttp
(this may work better in the future) I cannot match a Uri parse error in hyper to that of http with ease and combine them into a single BadUri enum. In fact, it's deeper than that in that the inner types for the Uri errors actually point to another struct and error kind.I also acknowledge that I'm still new to rust and this means that I might be missing a design pattern that I should use.
The text was updated successfully, but these errors were encountered: