'Exception handling helper.  This is used internally to either raise
rewritten exceptions or return a rendered traceback for the template.'

def handle_exception(self, exc_info=None, rendered=False, source_hint=None):

    global _make_traceback
    if (exc_info is None):
        exc_info = sys.exc_info()
    if (_make_traceback is None):
        from jinja2.debug import make_traceback as _make_traceback
    traceback = _make_traceback(exc_info, source_hint)
    if (rendered and (self.exception_formatter is not None)):
        return self.exception_formatter(traceback)
    if (self.exception_handler is not None):
        self.exception_handler(traceback)
    (exc_type, exc_value, tb) = traceback.standard_exc_info
    reraise(exc_type, exc_value, tb)
