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

Consider providing a shortcut for getting an error #33

Open
golddranks opened this issue Sep 15, 2016 · 0 comments
Open

Consider providing a shortcut for getting an error #33

golddranks opened this issue Sep 15, 2016 · 0 comments

Comments

@golddranks
Copy link

Having abort(something) is a wonderful shortcut! Let's have more of those.
It's quite common to have patterns like this:

let conn = ganbare::db_connect().map_err(|_| abort(500).unwrap_err())?;

Here, inside the map_err(), the return value ofabort(500) is too much – only the contents of the Err part of the Result is needed. That's why we need to do unwrap_err(). It's like creating an error, wrapping it up, tearing it open, just to wrap it up for returning, again.

Consider having a shortcut for creating http errors concisely :) How about http_err(500) or something like that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant