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
It is often needed for application to perform a fallible operation in its handler. Currently one needs to manually handle failures. Maybe there's a way to make it convenient. Ideally, one would just ? on results, but we need to distinguish parsing errors from internal errors. Two approaches that come to my mind:
let user_input = serde_json::from_slice::<UserInput>(request.body()).map_err(HandlingError::Request)?;
user_input.save_to_db().map_err(HandlingError::Internal)?;
What do you think?
The text was updated successfully, but these errors were encountered:
It is often needed for application to perform a fallible operation in its handler. Currently one needs to manually handle failures. Maybe there's a way to make it convenient. Ideally, one would just
?
on results, but we need to distinguish parsing errors from internal errors. Two approaches that come to my mind:The user would then implement
HandlingError
for their error type and could just?
errors.Another approach is to use just
enum
instead of atrait
:This could be used easily like this:
What do you think?
The text was updated successfully, but these errors were encountered: