1
"""Custom EvalException support
3
Provides template engine HTML error formatters for the Template tab of
10
import mako.exceptions
14
__all__ = ['handle_mako_error']
16
def handle_mako_error(context, exc):
18
exc.is_mako_exception = True
21
raise exc, None, sys.exc_info()[2]
24
def myghty_html_data(exc_value):
25
"""Format a Myghty exception as HTML"""
26
if hasattr(exc_value, 'htmlformat'):
27
return exc_value.htmlformat()[333:-14]
28
if hasattr(exc_value, 'mtrace'):
29
return exc_value.mtrace.htmlformat()[333:-14]
31
template_error_formatters = [myghty_html_data]
35
def mako_html_data(exc_value):
36
"""Format a Mako exception as HTML"""
37
if getattr(exc_value, 'is_mako_exception', False) or \
38
isinstance(exc_value, (mako.exceptions.CompileException,
39
mako.exceptions.SyntaxException)):
40
return mako.exceptions.html_error_template().render(full=False,
42
template_error_formatters.insert(0, mako_html_data)