-
-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
refactor: reduce use of unwrap #54
Conversation
WalkthroughThe changes primarily enhance error handling across several modules by replacing direct Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (8)
- crates/api_apub/src/users/user_followers.rs (1 hunks)
- crates/api_apub/src/users/user_outbox.rs (1 hunks)
- crates/api_mastodon/src/entities/context.rs (2 hunks)
- crates/api_mastodon/src/routes/statuses/status_favourited_by.rs (2 hunks)
- crates/api_mastodon/src/routes/statuses/status_reblogged_by.rs (2 hunks)
- crates/apub/src/actors/db_user.rs (1 hunks)
- crates/apub/src/actors/db_user_impl.rs (2 hunks)
- crates/feed/src/user_feed_item.rs (2 hunks)
Additional comments not posted (8)
crates/api_mastodon/src/entities/context.rs (1)
30-42
: Refactor to useTryJoinAll
improves error handling and control flow.The change from a direct collection of
Status
objects to usingTryJoinAll
ensures that errors in any of the asynchronous operations are properly propagated, preventing partial success states and improving overall robustness of the method.crates/api_mastodon/src/routes/statuses/status_favourited_by.rs (1)
41-51
: Use ofTryJoinAll
instatus_favourited_by
enhances error propagation.The replacement of a simpler collection pattern with
TryJoinAll
for handling relatedReceivedLike
entities ensures that all operations must succeed for the result to be considered valid. This change enhances error handling by not allowing partial successes which could lead to inconsistent states.crates/api_mastodon/src/routes/statuses/status_reblogged_by.rs (1)
41-51
: Consistent application ofTryJoinAll
instatus_reblogged_by
route.Implementing
TryJoinAll
in the handling ofReceivedAnnounce
entities ensures that errors in any part of the asynchronous operation are caught and handled appropriately, maintaining consistency with the changes in other parts of the codebase.crates/api_apub/src/users/user_followers.rs (1)
91-92
: Improved error handling withmap
andfilter_map(Result::ok)
in URL parsing.The refactoring to handle URL parsing errors more gracefully by using
map
andfilter_map(Result::ok)
instead of direct unwrapping prevents potential runtime panics due to malformed URLs, enhancing the robustness of the application.crates/api_apub/src/users/user_outbox.rs (1)
95-97
: Improved error handling in activity JSON conversion.The change from directly unwrapping the JSON conversion result to using
filter_map(Result::ok)
is a significant improvement. It prevents potential runtime panics that could occur if the conversion fails, thus enhancing the robustness of the code.crates/apub/src/actors/db_user_impl.rs (1)
96-108
: Enhanced error handling and concurrency in activity sending.The use of
TryJoinAll
for handling multiple asynchronous operations concurrently is a robust improvement. It ensures that all operations either succeed or fail together, providing better error propagation and simplifying error handling.crates/feed/src/user_feed_item.rs (1)
73-73
: Improved error handling in tag serialization and deserialization.The use of
and_then
withserde_json::from_str
andserde_json::to_string
for handling tag data is an excellent improvement. It ensures that errors in data format do not cause runtime exceptions, thus enhancing the robustness and reliability of the code.Also applies to: 101-101
crates/apub/src/actors/db_user.rs (1)
131-135
: Enhanced error handling in URL parsing for icons and images.The changes to use
and_then
withUrl::parse
followed bymap_or
for handling potential errors in URL parsing for user icons and images are commendable. This approach enhances error handling by gracefully managing parsing failures, thus preventing runtime exceptions.
Summary by CodeRabbit
Refactor
TryJoinAll
for better error control.Bug Fixes
unwrap()
calls with safer error handling methods.