-
Notifications
You must be signed in to change notification settings - Fork 123
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
FR: Custom error type in TryInto #315
Comments
Could you explain a bit why you want to use your own error type. In the v1.0.0 beta releases a dedicated error type is returned instead of a |
My use case is with generic types and traits which take a generic TryIntoError will probably address this. It would be more convenient |
Okay, so I thought about your usecase and I think it should be served just fine with a custom From implementation. And I don't think that that is really a lot more work/code than adding a dedicated method to your own type which takes the error string and Self as an argument. Because the From implementation would basically need the same except that these to arguments would be encapsulated in the TryIntoError type. So I'll close this as not planned. If I'm wrong and the amount of code needed to do what you want is actually a lot feel free to re-open and we can re-consider. |
I’d like to be able to use a custom error type with TryInto derive.
Ideally it would be possible to explicitly specify error type and
error constructor, for example something like:
If constructor is not specified a
From
conversion would be used.#170 is a related issue and it could be solved with similar approach
if the error constructor was given two arguments instead of just error
message. The example from that issue could look as follows:
The text was updated successfully, but these errors were encountered: