-
-
Notifications
You must be signed in to change notification settings - Fork 656
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
ServerFnError<T>
should impl From<E: std::error::Error>
for any T
#3153
Comments
nicolas-guichard
changed the title
Oct 23, 2024
ServerFnError<T>
should impl From<E>
for any T
ServerFnError<T>
should impl From<E: std::error::Error>
for any T
Feel free to make a PR. |
That trait implementation interferes with the one in core, so Rust won't let that happen. I'm also not sure people want to convert their E into a String instead of using our WrappedError variant. Closing this as well. |
nicolas-guichard
added a commit
to nicolas-guichard/leptos
that referenced
this issue
Nov 17, 2024
This adds 3 new traits: - `ConvertServerFnResult` provides easy conversion from `Result<T, ServerFnError<SourceCustErr>>` to `Result<T, ServerFnError<TargetCustError>>` when `TargetCustError` implements `From<SourceCustErr>` - `ConvertDefaultServerFnResult` provides easy conversion from `Result<T, ServerFnError<NoCustomError>` to `Result<T, ServerFnError<TargetCustError>>` - `IntoServerFnResult` provides easy conversion from `Result<T, E>` to `Result<T, ServerFnError::ServerError>` when `E` implements `std::error::Error` Fixes leptos-rs#3153 and leptos-rs#3155
nicolas-guichard
added a commit
to nicolas-guichard/leptos
that referenced
this issue
Nov 17, 2024
This adds 3 new traits: - `ConvertServerFnResult` provides easy conversion from `Result<T, ServerFnError<SourceCustErr>>` to `Result<T, ServerFnError<TargetCustError>>` when `TargetCustError` implements `From<SourceCustErr>` - `ConvertDefaultServerFnResult` provides easy conversion from `Result<T, ServerFnError<NoCustomError>` to `Result<T, ServerFnError<TargetCustError>>` - `IntoServerFnResult` provides easy conversion from `Result<T, E>` to `Result<T, ServerFnError::ServerError>` when `E` implements `std::error::Error` Fixes leptos-rs#3153 and leptos-rs#3155
nicolas-guichard
added a commit
to nicolas-guichard/leptos
that referenced
this issue
Nov 17, 2024
This adds 3 new traits: - `ConvertServerFnResult` provides easy conversion from `Result<T, ServerFnError<SourceCustErr>>` to `Result<T, ServerFnError<TargetCustError>>` when `TargetCustError` implements `From<SourceCustErr>` - `ConvertDefaultServerFnResult` provides easy conversion from `Result<T, ServerFnError<NoCustomError>` to `Result<T, ServerFnError<TargetCustError>>` - `IntoServerFnResult` provides easy conversion from `Result<T, E>` to `Result<T, ServerFnError::ServerError>` when `E` implements `std::error::Error` Fixes leptos-rs#3153 and leptos-rs#3155
7 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Currently,
ServerFnError
has a blanketFrom
impl to convert fromE
, but only with the defaultNoCustomError
type:This means we can't easily use
?
to convert other errors into aServerFnError<MyCustomError>
.Instead I think we should provide a blanket impl for any
T
:The text was updated successfully, but these errors were encountered: