fix: improve email activation error handling

- Add logging for successful email delivery
- Implement error handling for email sending failures
- Raise exceptions for further handling

This change improves the robustness of the email activation
process by logging outcomes and handling potential errors,
allowing for better debugging and monitoring of email
notifications.
This commit is contained in:
songtianlun 2025-01-08 18:00:25 +08:00
parent c130ffef90
commit f1f5e37d7b

View File

@ -64,7 +64,14 @@ class User < ApplicationRecord
end
def send_activation_email
UserMailer.account_activation(self).deliver_now
begin
result = UserMailer.account_activation(self).deliver_now
Rails.logger.info "Email sent successfully: #{result.inspect}"
rescue => e
Rails.logger.error "Failed to send email: #{e.message}"
Rails.logger.error e.backtrace.join("\n")
raise
end
end
def create_reset_digest