You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
The text was updated successfully, but these errors were encountered:
Having
abort(something)
is a wonderful shortcut! Let's have more of those.It's quite common to have patterns like this:
Here, inside the
map_err()
, the return value ofabort(500)
is too much – only the contents of theErr
part of theResult
is needed. That's why we need to dounwrap_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?The text was updated successfully, but these errors were encountered: