Skip to content

Commit

Permalink
Add exception logging when rendering the mail preview fails
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiask committed Nov 17, 2018
1 parent e60608e commit 8a4936c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions spark/spark_mails/admin.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import logging

from django.conf import settings
from django.contrib import admin
from django.utils.html import format_html
Expand All @@ -12,6 +14,7 @@
if getattr(settings, "SPARK_MAILS_CONTEXT", None)
else lambda instance: {}
)
logger = logging.getLogger(__name__)


@admin.register(Mail)
Expand All @@ -30,6 +33,7 @@ def rendered(self, instance):
**instance.render(spark_mails_context(instance)),
)
except Exception:
logger.exception("Error while rendering a preview of the mail.")
return format_html('<div style="color:red">INVALID</div>')

rendered.short_description = _("rendered")

0 comments on commit 8a4936c

Please sign in to comment.