Skip to content

Commit

Permalink
Log the rendering error
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiask committed Oct 30, 2018
1 parent f2636f9 commit 3878942
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Change log
- Slightly changed the signature of ``events_from_generators`` to accept
generator descriptions instead of a generator queryset to allow using
it without generator model instances.
- Protected ``process_mail_events`` against crashing templates.


`0.3`_ (2018-10-29)
Expand Down
8 changes: 6 additions & 2 deletions spark/spark_mails/api.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import logging

from django.core.mail import EmailMessage

from spark.spark_mails.models import Mail


logger = logging.getLogger(__name__)


def process_mail_events(iterable, *, defaults=None, fail_silently=False):
mails = {m.event_group: m for m in Mail.objects.all()}

Expand All @@ -15,8 +20,7 @@ def process_mail_events(iterable, *, defaults=None, fail_silently=False):
try:
subject, body = mails[e["group"]].render(e["context"])
except Exception:
# TODO logging
pass
logger.exception("Error while rendering mail subject and body")
else:
if subject:
kwargs["subject"] = subject
Expand Down

0 comments on commit 3878942

Please sign in to comment.