Ejemplo n.º 1
0
    def test_simple(self):
        try:
            self.raise_(4)
        except RuntimeError:
            tb = sys.exc_info()[2]
            tb_cut = addonmanager.cut_traceback(tb, "test_simple")
            assert len(traceback.extract_tb(tb_cut)) == 5

            tb_cut2 = addonmanager.cut_traceback(tb, "nonexistent")
            assert len(traceback.extract_tb(tb_cut2)) == len(traceback.extract_tb(tb))
Ejemplo n.º 2
0
def script_error_handler(path, exc, msg="", tb=False):
    """
        Handles all the user's script errors with
        an optional traceback
    """
    exception = type(exc).__name__
    if msg:
        exception = msg
    lineno = ""
    if hasattr(exc, "lineno"):
        lineno = str(exc.lineno)
    log_msg = "in script {}:{} {}".format(path, lineno, exception)
    if tb:
        etype, value, tback = sys.exc_info()
        tback = addonmanager.cut_traceback(tback, "invoke_addon")
        log_msg = log_msg + "\n" + "".join(traceback.format_exception(etype, value, tback))
    ctx.log.error(log_msg)
Ejemplo n.º 3
0
def script_error_handler(path, exc, msg="", tb=False):
    """
        Handles all the user's script errors with
        an optional traceback
    """
    exception = type(exc).__name__
    if msg:
        exception = msg
    lineno = ""
    if hasattr(exc, "lineno"):
        lineno = str(exc.lineno)
    log_msg = "in script {}:{} {}".format(path, lineno, exception)
    if tb:
        etype, value, tback = sys.exc_info()
        tback = addonmanager.cut_traceback(tback, "invoke_addon")
        log_msg = log_msg + "\n" + "".join(traceback.format_exception(etype, value, tback))
    ctx.log.error(log_msg)