From d0a422f6749091582d3f4b94e7fda9869b9ed4e4 Mon Sep 17 00:00:00 2001 From: hernani Date: Sat, 10 Jul 2010 12:14:26 +0000 Subject: [PATCH] Wraps the markdowner call with a try except block, and logs the possible errors. git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@517 0cfe37f9-358a-4d5e-be75-b63607b5c754 --- forum/models/node.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/forum/models/node.py b/forum/models/node.py index a8c674c..6d8a483 100644 --- a/forum/models/node.py +++ b/forum/models/node.py @@ -25,7 +25,13 @@ class NodeContent(models.Model): @classmethod def _as_markdown(cls, content, *extensions): - return mark_safe(sanitize_html(markdown.markdown(content, extensions=extensions))) + try: + return mark_safe(sanitize_html(markdown.markdown(content, extensions=extensions))) + except Exception, e: + import traceback + logging.error("Caught exception %s in markdown parser rendering %s %s:\s %s" % ( + str(e), cls.__name__, str(e), traceback.format_exc())) + return '' def as_markdown(self, *extensions): return self._as_markdown(self.body, *extensions) -- 2.39.5