Add error handling for email sending in send_notification#1050
Add error handling for email sending in send_notification#1050aanyacloud wants to merge 1 commit into
Conversation
This PR improves the robustness of the send_notification function by adding error handling around the email sending logic. Changes: - Wrapped send_mail in a try-except block - Added logging for failures This ensures that notification creation is not interrupted if email sending fails, improving reliability and consistency with existing patterns in the codebase.
👀 Peer Review RequiredHi @aanyacloud! This pull request does not yet have a peer review. Before this PR can be merged, please request a review from one of your peers:
Thank you for contributing! 🎉 |
🚚 This Repository Is MovingHi @aanyacloud, thank you for your contribution! We are in the process of migrating most of the logic from this repository to our new repository: alphaonelabs/learn. What this means for your PRPlease do not merge or continue work here. Instead:
This PR has been automatically closed. Once you have opened your PR in the new repository, feel free to reference it here. Thank you for your understanding and continued support! 🙏 |
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: alphaonelabs/coderabbit/.coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThe Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This PR improves the robustness of the send_notification function by adding error handling around the email sending logic.
Changes:
This ensures that notification creation is not interrupted if email sending fails, improving reliability and consistency with existing patterns in the codebase.
Summary
Changes Made
The
send_notification()function inweb/notifications.pynow includes error handling for email sending. Thesend_mail()call has been wrapped in a try-except block that catches any exceptions during email transmission.Key Modifications
send_mail()call to gracefully handle email sending failureslogger.error()that records both the target user email address and the exception detailsnotificationobject even if email sending failsPurpose & Impact
This change ensures that notification creation is not interrupted by email service failures, aligning with existing codebase patterns. By catching and logging exceptions rather than allowing them to propagate, the system becomes more resilient. Notifications are successfully persisted to the database regardless of email delivery issues, while detailed error logs enable troubleshooting of email backend problems. This prevents external service failures from disrupting the notification workflow in production environments.
Technical Details