refactor: Replace direct logger.error calls with capture_and_log in accounts services and conditionally pass error_id during ApplicationError creation.

This commit is contained in:
pacnpal
2026-01-04 18:36:23 -05:00
parent 95700c7d7b
commit bc4a3c7557
6 changed files with 40 additions and 27 deletions

View File

@@ -26,6 +26,7 @@ from django.utils.crypto import get_random_string
from django_forwardemail.services import EmailService
from .models import EmailVerification, User, UserDeletionRequest, UserProfile
from apps.core.utils import capture_and_log
logger = logging.getLogger(__name__)
@@ -130,7 +131,7 @@ class AccountService:
html=email_html,
)
except Exception as e:
logger.error(f"Failed to send password change confirmation email: {e}")
capture_and_log(e, 'Send password change confirmation email', source='service', severity='medium')
@staticmethod
def initiate_email_change(
@@ -206,7 +207,7 @@ class AccountService:
html=email_html,
)
except Exception as e:
logger.error(f"Failed to send email verification: {e}")
capture_and_log(e, 'Send email verification', source='service', severity='medium')
@staticmethod
def verify_email_change(*, token: str) -> dict[str, Any]: