mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-25 03:58:39 +02:00
Review feedback: exception handling
This commit is contained in:
parent
ce9c8abd60
commit
e4233870d6
3 changed files with 38 additions and 13 deletions
|
@ -1,3 +1,5 @@
|
|||
import logging
|
||||
|
||||
from django.contrib.auth.models import AbstractUser
|
||||
from django.db import models
|
||||
|
||||
|
@ -6,6 +8,9 @@ from .domain_invitation import DomainInvitation
|
|||
from phonenumber_field.modelfields import PhoneNumberField # type: ignore
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class User(AbstractUser):
|
||||
"""
|
||||
A custom user model that performs identically to the default user model
|
||||
|
@ -43,5 +48,11 @@ class User(AbstractUser):
|
|||
for invitation in DomainInvitation.objects.filter(
|
||||
email=self.email, status=DomainInvitation.INVITED
|
||||
):
|
||||
invitation.retrieve()
|
||||
invitation.save()
|
||||
try:
|
||||
invitation.retrieve()
|
||||
invitation.save()
|
||||
except RuntimeError:
|
||||
# retrieving should not fail because of a missing user, but
|
||||
# if it does fail, log the error so a new user can continue
|
||||
# logging in
|
||||
logger.warn("Failed to retrieve invitation %s", invitation, exc_info=True)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue