Skip to content

Commit 2dddd02

Browse files
committed
More-Like-This template tag: log exceptions’
Not preventing the page from rendering is fine but they should be logged, ideally in a Sentry-friendly manner
1 parent fcb8ced commit 2dddd02

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

haystack/templatetags/more_like_this.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
from __future__ import absolute_import, division, print_function, unicode_literals
44

5+
import logging
6+
57
from django import template
68

79
from haystack.query import SearchQuerySet
@@ -44,8 +46,10 @@ def render(self, context):
4446
sqs = sqs[: self.limit]
4547

4648
context[self.varname] = sqs
47-
except:
48-
pass
49+
except Exception as exc:
50+
logging.warning(
51+
"Unhandled exception rendering %r: %s", self, exc, exc_info=True
52+
)
4953

5054
return ""
5155

0 commit comments

Comments
 (0)