From eb2c6a171affed851535efa15f2f3aaa47d11d40 Mon Sep 17 00:00:00 2001 From: rjollos Date: Mon, 25 Sep 2023 00:13:24 +0000 Subject: [PATCH] 1.6.1dev: Merge r17650 from 1.4-stable Refs #13515 git-svn-id: http://trac.edgewall.org/intertrac/log:/branches/1.6-stable@17725 af82e41b-90c4-0310-8c96-b1721e28e2e2 --- trac/notification/api.py | 13 ++++++++++++- trac/ticket/web_ui.py | 6 +++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/trac/notification/api.py b/trac/notification/api.py index 3c4e45492b..a111493bb6 100644 --- a/trac/notification/api.py +++ b/trac/notification/api.py @@ -22,6 +22,7 @@ ListOption, Option) from trac.core import Component, Interface, ExtensionPoint from trac.util import as_bool, lazy, to_list +from trac.util.text import exception_to_unicode __all__ = ['IEmailAddressResolver', 'IEmailDecorator', 'IEmailSender', @@ -208,6 +209,11 @@ def __init__(self, realm, category, target, time, author=""): self.time = time self.author = author + def __repr__(self): + return '<%s realm=%r, category=%r, target=%r, time=%r, author=%r>' % \ + (self.__class__.__name__, self.realm, self.category, + self.target, self.time, self.author) + class NotificationSystem(Component): @@ -353,7 +359,12 @@ def notify(self, event): :param event: a `NotificationEvent` """ - self.distribute_event(event, self.subscriptions(event)) + try: + self.distribute_event(event, self.subscriptions(event)) + except Exception as e: + self.log.error("Failure distributing event %r%s", event, + exception_to_unicode(e, traceback=True)) + raise def distribute_event(self, event, subscriptions): """Distribute a event to all subscriptions. diff --git a/trac/ticket/web_ui.py b/trac/ticket/web_ui.py index 92347212a0..79e152c872 100644 --- a/trac/ticket/web_ui.py +++ b/trac/ticket/web_ui.py @@ -1347,7 +1347,7 @@ def _do_create(self, req, ticket, action): except Exception as e: self.log.error("Failure sending notification on creation of " "ticket #%s: %s", - ticket.id, exception_to_unicode(e, traceback=True)) + ticket.id, exception_to_unicode(e)) add_warning(req, tag_("The ticket has been created, but an error " "occurred while sending notifications: " "%(message)s", message=to_fragment(e))) @@ -1387,8 +1387,8 @@ def _do_save(self, req, ticket, action): NotificationSystem(self.env).notify(event) except Exception as e: self.log.error("Failure sending notification on change to " - "ticket #%s: %s", ticket.id, - exception_to_unicode(e, traceback=True)) + "ticket #%s: %s", + ticket.id, exception_to_unicode(e)) # TRANSLATOR: The 'change' has been saved... (link) change = _('change') if fragment: