Mercurial > kallithea
changeset 2747:cdce3d7282b2 beta
catch errors on renderers, and display plain if critical rendering error is present
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Mon, 27 Aug 2012 10:15:36 +0200 |
parents | 49a4864b11c1 |
children | dfb15c8ee63f |
files | rhodecode/lib/markup_renderer.py |
diffstat | 1 files changed, 15 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/rhodecode/lib/markup_renderer.py Sun Aug 26 01:04:43 2012 +0200 +++ b/rhodecode/lib/markup_renderer.py Mon Aug 27 10:15:36 2012 +0200 @@ -26,6 +26,7 @@ import re import logging +import traceback from rhodecode.lib.utils2 import safe_unicode, MENTIONS_REGEX @@ -93,7 +94,7 @@ return '<br />' + source.replace("\n", '<br />') @classmethod - def markdown(cls, source): + def markdown(cls, source, safe=True): source = safe_unicode(source) try: import markdown as __markdown @@ -101,9 +102,15 @@ except ImportError: log.warning('Install markdown to use this function') return cls.plain(source) + except Exception: + log.error(traceback.format_exc()) + if safe: + return source + else: + raise @classmethod - def rst(cls, source): + def rst(cls, source, safe=True): source = safe_unicode(source) try: from docutils.core import publish_parts @@ -125,6 +132,12 @@ except ImportError: log.warning('Install docutils to use this function') return cls.plain(source) + except Exception: + log.error(traceback.format_exc()) + if safe: + return source + else: + raise @classmethod def rst_with_mentions(cls, source):