Skip to content
Snippets Groups Projects
Commit b0bba742 authored by vlorentz's avatar vlorentz
Browse files

mailmaps: Avoid false positive when checking IntegrityError.

parent 9ebe0aee
No related branches found
No related tags found
No related merge requests found
......@@ -57,8 +57,11 @@ def profile_add_mailmap(request: Request) -> HttpResponse:
UserMailmap.objects.create(
user_id=str(request.user.id), from_email=from_email, **request.data
)
except IntegrityError:
return HttpResponseBadRequest("This 'from_email' already exists.")
except IntegrityError as e:
if "user_mailmap_from_email_key" in e.args[0]:
return HttpResponseBadRequest("This 'from_email' already exists.")
else:
raise
event.successful = True
event.save()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment