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
Currently, there are a lot of places where I use Result.expect() to panic on unexpected behavior. Most notably in RestApiClient.send_api_request(). It is more idiomatic rust to handle errors in the caller instead of arbitrarily throwing panics.
This solution may be considered a refactor since there are so many instances where the code calls Result.expect(), or Result.unwrap() (same as .expect() but without customized error message).
Note
There are some instances where it makes sense to use .unwrap(), but it should be determined by the code block's local context.
TBH, this problem was born from the fact that this is my first rust project. I should have picked a more robust design from the start.
The text was updated successfully, but these errors were encountered:
Currently, there are a lot of places where I use
Result.expect()
to panic on unexpected behavior. Most notably inRestApiClient.send_api_request()
. It is more idiomatic rust to handle errors in the caller instead of arbitrarily throwing panics.This solution may be considered a refactor since there are so many instances where the code calls
Result.expect()
, orResult.unwrap()
(same as.expect()
but without customized error message).Note
There are some instances where it makes sense to use
.unwrap()
, but it should be determined by the code block's local context.TBH, this problem was born from the fact that this is my first rust project. I should have picked a more robust design from the start.
The text was updated successfully, but these errors were encountered: