Modify ↓
Opened 9 years ago
Closed 9 years ago
#12768 closed defect (fixed)
Exceptions from navigation contributor always should be logged
| Reported by: | Jun Omae | Owned by: | Jun Omae |
|---|---|---|---|
| Priority: | normal | Milestone: | 1.0.14 |
| Component: | general | Version: | |
| Severity: | normal | Keywords: | |
| Cc: | Branch: | ||
| Release Notes: |
An exception from navigation contributors is logged, now. |
||
| 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): 810 810 except Exception, e: 811 811 name = contributor.__class__.__name__ 812 812 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)) 815 815 else: 816 816 self.log.error("Error with navigation contributor %s: %s", 817 name, exception_to_unicode(e)) 817 name, 818 exception_to_unicode(e, traceback=True)) 818 819 add_warning(req, _("Error with navigation contributor " 819 820 '"%(name)s"', name=name)) 820 821
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):
...
Attachments (0)
Change History (4)
comment:1 by , 9 years ago
comment:3 by , 9 years ago
| Milestone: | next-stable-1.0.x → 1.0.14 |
|---|---|
| Owner: | set to |
| Status: | new → assigned |
Thanks. I'm going to push it to 1.0-stable.
comment:4 by , 9 years ago
| Release Notes: | modified (diff) |
|---|---|
| Resolution: | → fixed |
| Status: | assigned → closed |
Committed in [15791] and merged in [15792-15793].
After the changes, the following would be logged.
2017-04-17 15:26:08,669 Trac[chrome] WARNING: Error with navigation contributor AboutModule: TracError: xxx
2017-04-17 15:26:36,242 Trac[chrome] ERROR: Error with navigation contributor AboutModule:
Traceback (most recent call last):
File "/src/tracdev/svn/branches/1.0-stable/trac/web/chrome.py", line 786, in prepare_request
contributor.get_navigation_items(req) or []:
File "/src/tracdev/svn/branches/1.0-stable/trac/about.py", line 47, in get_navigation_items
raise ValueError('xxx')
ValueError: xxx
Note:
See TracTickets
for help on using tickets.



Sounds good. Looks like a duplicate of #12428.