Skip to content

Commit

Permalink
Handle more types of errors in user deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
ffont committed Dec 15, 2023
1 parent 62e60b7 commit d9aa002
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion accounts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
from django.urls import reverse
from django.utils.encoding import smart_str
from django.utils.timezone import now
from psycopg2.errors import ForeignKeyViolation

import tickets.models
from apiv2.models import ApiV2Client
Expand Down Expand Up @@ -489,7 +490,7 @@ def delete_user(self, remove_sounds=False,
with transaction.atomic():
try:
Sound.objects.filter(id__in=chunk_ids).delete()
except IntegrityError:
except (IntegrityError, ForeignKeyViolation) as e:
num_errors += 1
num_sounds = Sound.objects.filter(user=self.user).count()

Expand Down

0 comments on commit d9aa002

Please sign in to comment.