diff options
author | designst <info@designstage.ch> | 2014-05-21 16:08:11 +0200 |
---|---|---|
committer | designst <info@designstage.ch> | 2014-05-21 16:08:11 +0200 |
commit | 0aafca82e94b780c5ce2c178d7d4ee18bcd2ab41 (patch) | |
tree | df0b0f3a78bd4589a859c270d7aaa2320795aaf2 | |
parent | c094a8adaac6aff481c9708fe91d71fae21cad87 (diff) | |
download | mako-0aafca82e94b780c5ce2c178d7d4ee18bcd2ab41.tar.gz |
reraise more exception information if template error_handler is defined
-rw-r--r-- | mako/runtime.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/mako/runtime.py b/mako/runtime.py index d7b9681..c968264 100644 --- a/mako/runtime.py +++ b/mako/runtime.py @@ -852,18 +852,25 @@ def _exec_template(callable_, context, args=None, kwargs=None): try: callable_(context, *args, **kwargs) except Exception: - _render_error(template, context, compat.exception_as()) + _render_error(template, context, compat.exception_as(), sys.exc_info()) except: e = sys.exc_info()[0] _render_error(template, context, e) else: callable_(context, *args, **kwargs) -def _render_error(template, context, error): +def _render_error(template, context, error, exc_info=None): if template.error_handler: result = template.error_handler(context, error) if not result: - raise error + if exc_info: + t, v, tb = exc_info + if sys.version_info[0] <= 2: + exec('raise v, None, tb.tb_next') + else: + raise v.with_traceback(tb.tb_next) + else: + raise error else: error_template = exceptions.html_error_template() if context._outputting_as_unicode: |