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

Rename EndpointResult to Result #235

Closed
yoshuawuyts opened this issue May 19, 2019 · 2 comments
Closed

Rename EndpointResult to Result #235

yoshuawuyts opened this issue May 19, 2019 · 2 comments
Assignees
Labels
feature A feature that's ready for implementation

Comments

@yoshuawuyts
Copy link
Member

I've been thinking of ways to improve the error handling story in tide, related to #138, and one of the things that came up is that tide::EndpointResult is quite inconvenient to type.

I'd like to propose we rename this to tide::Result instead, and document that it's intended for use in endpoints. We can then provide examples of the Into conversions on the Result type too, which should help with documenting what valid responses are.

Proposed

async fn new_message(mut cx: Context<Database>) -> tide::Result<String> {
    let msg = cx.body_json().await.client_err()?;
    Ok(cx.state().insert(msg).to_string())
}

Current

use tide::EndpointResult;

async fn new_message(mut cx: Context<Database>) -> EndpointResult<String> {
    let msg = cx.body_json().await.client_err()?;
    Ok(cx.state().insert(msg).to_string())
}
@yoshuawuyts yoshuawuyts added the feature A feature that's ready for implementation label May 19, 2019
@yoshuawuyts yoshuawuyts self-assigned this May 19, 2019
@prasannavl
Copy link
Contributor

prasannavl commented May 26, 2019

PR #258 moves EndpointResult into endpoint, which should make it a little more natural. Meanwhile, I think it's more relevant to move this into tide::Result when this type can cover a larger ground than just endpoints - possibly be more consistent around middlewares as well. (as in, Middleware today return a future of Response -- if it returns a future of this proposed Result too, then I think it's scope expands into a larger a tide::Result). But that's a larger discussion that requires error handling to be nailed out first to know that the Error type of this Result is going to be. Currently in today's state, I think it's only relevant to endpoints only.

@phansch
Copy link
Contributor

phansch commented Apr 7, 2020

@yoshuawuyts I think this can be closed as it has been renamed in 5a2bbd5?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A feature that's ready for implementation
Projects
None yet
Development

No branches or pull requests

3 participants