Catch errors in Django-Q2 email reporter

This commit is contained in:
Adam Goldsmith 2024-01-05 14:37:02 -05:00
parent 188824d53b
commit da0767a0e9

View File

@ -1,4 +1,5 @@
import sys import sys
import traceback
from django.views.debug import ExceptionReporter from django.views.debug import ExceptionReporter
from django.core import mail from django.core import mail
@ -9,6 +10,7 @@ class AdminEmailReporter:
pass pass
def report(self): def report(self):
try:
reporter = ExceptionReporter(None, *sys.exc_info()) reporter = ExceptionReporter(None, *sys.exc_info())
message = f"Failed to run task\n{reporter.get_traceback_text()}" message = f"Failed to run task\n{reporter.get_traceback_text()}"
html_message = reporter.get_traceback_html() html_message = reporter.get_traceback_html()
@ -18,3 +20,5 @@ class AdminEmailReporter:
# fail_silently=True, # fail_silently=True,
html_message=html_message, html_message=html_message,
) )
except Exception:
print(traceback.format_exc())