Skip to content
This repository was archived by the owner on Jan 14, 2023. It is now read-only.

Raise verbose errors when failing to save a user #35

Open
jeancochrane opened this issue Jun 17, 2020 · 0 comments
Open

Raise verbose errors when failing to save a user #35

jeancochrane opened this issue Jun 17, 2020 · 0 comments

Comments

@jeancochrane
Copy link

If a user signs up but something is wrong with the database such that an IntegrityError gets raised, the code will currently suppress the error and show a generic error to the user:

try:
user = form.save()
redirect = reverse('index')
if request.GET.get('next'):
redirect = request.GET['next']
host = '{0}://{1}'.format(request.scheme, request.get_host())
send_signup_email(user, host, redirect)
messages.add_message(request, messages.INFO, 'Check your email for a link to confirm your account!')
return HttpResponseRedirect(redirect)
except IntegrityError:
response = HttpResponse('Not able to save form.')
response.status_code = 500
return response

This happened recently when the primary key sequence for the auth_user table got out of sync, causing an IntegrityError to get raised by form.save().

We should make sure that we log this error to Sentry so that we can diagnose the error without having to interrupt the running application.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant