Catch errors in Django-Q2 email reporter
This commit is contained in:
parent
edd26e3f75
commit
6ca6f1390c
@ -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,12 +10,15 @@ class AdminEmailReporter:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def report(self):
|
def report(self):
|
||||||
reporter = ExceptionReporter(None, *sys.exc_info())
|
try:
|
||||||
message = f"Failed to run task\n{reporter.get_traceback_text()}"
|
reporter = ExceptionReporter(None, *sys.exc_info())
|
||||||
html_message = reporter.get_traceback_html()
|
message = f"Failed to run task\n{reporter.get_traceback_text()}"
|
||||||
mail.mail_admins(
|
html_message = reporter.get_traceback_html()
|
||||||
"Django Q task failed",
|
mail.mail_admins(
|
||||||
message,
|
"Django Q task failed",
|
||||||
# fail_silently=True,
|
message,
|
||||||
html_message=html_message,
|
# fail_silently=True,
|
||||||
)
|
html_message=html_message,
|
||||||
|
)
|
||||||
|
except Exception:
|
||||||
|
print(traceback.format_exc())
|
||||||
|
Loading…
Reference in New Issue
Block a user