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

Improve error handling user experience. #2665

Closed
wants to merge 1 commit into from

Commits on Mar 21, 2024

  1. Add new traits and types to improve error handling user experience.

    Adds the trait `IntoResultResponse` to be use in place of
    `IntoResponse` in handlers to allow easy use of `?` on standard errors
    and other implementations like `anyhow` and `eyre`.
    
    The type `ErrorResponse` encapsulate any kind of error with an associated
    `StatusCode` and the type alias `ResultResponse` use it by default in a
    `Result`.
    
    `ErrorResponse` can be converted from any `Into<Box<dyn Error>>` and
    also implements `IntoResponse`.
    
    `IntoResultResponse` is only implemented by `ResultResponse` to force the
    type system to unambiguously convert any errors from handlers to
    `ErrorResponse` when using `?`.
    
    This commits only add new traits and types doesn't change any existing
    API.
    PaulGrandperrin committed Mar 21, 2024
    Configuration menu
    Copy the full SHA
    cd9de54 View commit details
    Browse the repository at this point in the history