Edgewall Software

Opened 7 years ago

Last modified 7 years ago

#12768 closed defect

Exceptions from navigation contributor always should be logged — at Initial Version

Reported by: Jun Omae Owned by:
Priority: normal Milestone: 1.0.14
Component: general Version:
Severity: normal Keywords:
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

Exception's message from navigation contributor is not logged. I cannot investigate issues from the contributors caused by this behavior.

  • trac/web/chrome.py

    diff --git a/trac/web/chrome.py b/trac/web/chrome.py
    index cdf50e9d7..afe9a2850 100644
    a b class Chrome(Component):  
    810810            except Exception, e:
    811811                name = contributor.__class__.__name__
    812812                if isinstance(e, TracError):
    813                     self.log.warning("Error with navigation contributor %s",
    814                                      name)
     813                    self.log.warning("Error with navigation contributor %s: "
     814                                     "%s", name, exception_to_unicode(e))
    815815                else:
    816816                    self.log.error("Error with navigation contributor %s: %s",
    817                                    name, exception_to_unicode(e))
     817                                   name,
     818                                   exception_to_unicode(e, traceback=True))
    818819                add_warning(req, _("Error with navigation contributor "
    819820                                   '"%(name)s"', name=name))
    820821

For now, patch like this is applied to all contributors in my environment to catch the same issue:

diff --git a/foobar/foobar/web_ui.py b/foobar/foobar/web_ui.py
index ade158b8..44b94eb9 100644
--- a/foobar/foobar/web_ui.py
+++ b/foobar/foobar/web_ui.py
@@ -1022,6 +1022,14 @@
         return None

     def get_navigation_items(self, req):
+        try:
+            return self._get_navigation_items(req)
+        except:
+            self.log.error('Exception caught in %s', self.__class__.__name__,
+                           exc_info=True)
+            return []
+
+    def _get_navigation_items(self, req):
         ...

Change History (0)

Note: See TracTickets for help on using tickets.