Skip to content
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

Improvements around custom error handling in ServerFnError #3253

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Commits on Nov 17, 2024

  1. Change NoCustomError to be an empty enum

    Contrary to an empty struct, which has exactly 1 possible value, an
    empty enum has 0 possible values: it can't even be constructed.
    
    Fixes leptos-rs#3154
    nicolas-guichard committed Nov 17, 2024
    Configuration menu
    Copy the full SHA
    3d4b681 View commit details
    Browse the repository at this point in the history
  2. Provide conversion utilities around Result<T, ServerFnError<E>>

    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 committed Nov 17, 2024
    Configuration menu
    Copy the full SHA
    a9ad221 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    8f2cf7a View commit details
    Browse the repository at this point in the history