AdminZulipHandler: Don't print extra traceback for logged-out users.

This is not an interesting condition worth highlighting for sysadmins.

Fixes #3963.
This commit is contained in:
Tim Abbott 2017-03-07 21:08:42 -08:00
parent b1e7ecdad2
commit 6e442902e1
1 changed files with 8 additions and 3 deletions

View File

@ -38,12 +38,17 @@ class AdminZulipHandler(logging.Handler):
stack_trace = None
try:
from django.contrib.auth.models import AnonymousUser
user_profile = request.user
if isinstance(user_profile, AnonymousUser):
user_full_name = None
user_email = None
else:
user_full_name = user_profile.full_name
user_email = user_profile.email
except Exception:
# Unexpected exceptions here should be handled gracefully
traceback.print_exc()
# Error was triggered by an anonymous user.
user_full_name = None
user_email = None