-
-
Notifications
You must be signed in to change notification settings - Fork 655
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<TargetErr>
should impl From<ServerFnError<SourceErr>>
where TargetErr: From<SourceErr>
#3155
Comments
Again, feel free to make a PR if the compiler will actually allow this. |
This one also conflicts with an existing trait, this time in convert
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Last one in my series of proposed improvements to
ServerFnError
: we could provide a conversion fromServerFnError<OldCustErr>
toServerFnError<NewCustErr>
ifNewCustErr: From<OldCustErr>
. Something like:The typical use-case I have is helper functions that can fail in one or two ways, shared by multiple server functions that can also fail in other ways.
The text was updated successfully, but these errors were encountered: