Ejemplo n.º 1
0
def nested_call_timing(errated=True):
    if errated:
        startfunc = nf1
    else:
        startfunc = f1

    startfunc(100, 100)  # never raise, never catch
    if errated:
        _ = get_narration()
Ejemplo n.º 2
0
def nested_call_timing(errated=True):
    if errated:
        startfunc = nf1
    else:
        startfunc = f1

    startfunc(100, 100)  # never raise, never catch
    if errated:
        _ = get_narration()
Ejemplo n.º 3
0
def f1(arg1, arg2):
    # do some things, then
    try:
        f2(arg1+1, arg2+1)
    except Exception as e:
        lines = ["My thread {}'s story:".format(
                 threading.current_thread().name)]
        lines.extend([s for s in get_narration()])
        print("\n".join(lines))
        print("")
Ejemplo n.º 4
0
def nf9(borkfunc, catchfunc):
    if borkfunc == 9:
        raise Exception("bork9")
    else:
        try:
            nf10(borkfunc, catchfunc)
        except Exception:
            if catchfunc == 9:
                _ = get_narration()
            else:
                raise
Ejemplo n.º 5
0
def nf8(borkfunc, catchfunc):
    if borkfunc == 8:
        raise Exception("bork8")
    else:
        try:
            nf9(borkfunc, catchfunc)
        except Exception:
            if catchfunc == 8:
                _ = get_narration()
            else:
                raise
Ejemplo n.º 6
0
def f7(borkfunc, catchfunc):
    if borkfunc == 7:
        raise Exception("bork7")
    else:
        try:
            f8(borkfunc, catchfunc)
        except Exception:
            if catchfunc == 7:
                _ = get_narration()
            else:
                raise
Ejemplo n.º 7
0
def nf6(borkfunc, catchfunc):
    if borkfunc == 6:
        raise Exception("bork6")
    else:
        try:
            nf7(borkfunc, catchfunc)
        except Exception:
            if catchfunc == 6:
                _ = get_narration()
            else:
                raise
Ejemplo n.º 8
0
def f5(borkfunc, catchfunc):
    if borkfunc == 5:
        raise Exception("bork5")
    else:
        try:
            f6(borkfunc, catchfunc)
        except Exception:
            if catchfunc == 5:
                _ = get_narration()
            else:
                raise
Ejemplo n.º 9
0
def f4(borkfunc, catchfunc):
    if borkfunc == 4:
        raise Exception("bork4")
    else:
        try:
            f5(borkfunc, catchfunc)
        except Exception:
            if catchfunc == 4:
                _ = get_narration()
            else:
                raise
Ejemplo n.º 10
0
def nf3(borkfunc, catchfunc):
    if borkfunc == 3:
        raise Exception("bork3")
    else:
        try:
            nf4(borkfunc, catchfunc)
        except Exception:
            if catchfunc == 3:
                _ = get_narration()
            else:
                raise
Ejemplo n.º 11
0
def f1(borkfunc, catchfunc):
    if borkfunc == 1:
        raise Exception("bork1")
    else:
        try:
            f2(borkfunc, catchfunc)
        except Exception:
            if catchfunc == 1:
                _ = get_narration()
            else:
                raise
Ejemplo n.º 12
0
def f2(borkfunc, catchfunc):
    if borkfunc == 2:
        raise Exception("bork2")
    else:
        try:
            f3(borkfunc, catchfunc)
        except Exception:
            if catchfunc == 2:
                _ = get_narration()
            else:
                raise
Ejemplo n.º 13
0
def nf9(borkfunc, catchfunc):
    if borkfunc == 9:
        raise Exception("bork9")
    else:
        try:
            nf10(borkfunc, catchfunc)
        except Exception:
            if catchfunc == 9:
                _ = get_narration()
            else:
                raise
Ejemplo n.º 14
0
def nf8(borkfunc, catchfunc):
    if borkfunc == 8:
        raise Exception("bork8")
    else:
        try:
            nf9(borkfunc, catchfunc)
        except Exception:
            if catchfunc == 8:
                _ = get_narration()
            else:
                raise
Ejemplo n.º 15
0
def f7(borkfunc, catchfunc):
    if borkfunc == 7:
        raise Exception("bork7")
    else:
        try:
            f8(borkfunc, catchfunc)
        except Exception:
            if catchfunc == 7:
                _ = get_narration()
            else:
                raise
Ejemplo n.º 16
0
def nf6(borkfunc, catchfunc):
    if borkfunc == 6:
        raise Exception("bork6")
    else:
        try:
            nf7(borkfunc, catchfunc)
        except Exception:
            if catchfunc == 6:
                _ = get_narration()
            else:
                raise
Ejemplo n.º 17
0
def f5(borkfunc, catchfunc):
    if borkfunc == 5:
        raise Exception("bork5")
    else:
        try:
            f6(borkfunc, catchfunc)
        except Exception:
            if catchfunc == 5:
                _ = get_narration()
            else:
                raise
Ejemplo n.º 18
0
def f4(borkfunc, catchfunc):
    if borkfunc == 4:
        raise Exception("bork4")
    else:
        try:
            f5(borkfunc, catchfunc)
        except Exception:
            if catchfunc == 4:
                _ = get_narration()
            else:
                raise
Ejemplo n.º 19
0
def nf3(borkfunc, catchfunc):
    if borkfunc == 3:
        raise Exception("bork3")
    else:
        try:
            nf4(borkfunc, catchfunc)
        except Exception:
            if catchfunc == 3:
                _ = get_narration()
            else:
                raise
Ejemplo n.º 20
0
def f1(borkfunc, catchfunc):
    if borkfunc == 1:
        raise Exception("bork1")
    else:
        try:
            f2(borkfunc, catchfunc)
        except Exception:
            if catchfunc == 1:
                _ = get_narration()
            else:
                raise
Ejemplo n.º 21
0
def f2(borkfunc, catchfunc):
    if borkfunc == 2:
        raise Exception("bork2")
    else:
        try:
            f3(borkfunc, catchfunc)
        except Exception:
            if catchfunc == 2:
                _ = get_narration()
            else:
                raise
Ejemplo n.º 22
0
def do_it(errated=True):
    if errated:
        startfunc = nf1
    else:
        startfunc = f1

    for bf in range(1, 11):
        for cf in range(1, bf):
            try:
                startfunc(bf, cf)
            except Exception:
                if errated:
                    _ = get_narration()
Ejemplo n.º 23
0
def do_it(errated=True):
    if errated:
        startfunc = nf1
    else:
        startfunc = f1

    for bf in range(1, 11):
        for cf in range(1, bf):
            try:
                startfunc(bf, cf)
            except Exception:
                if errated:
                    _ = get_narration()
Ejemplo n.º 24
0
from errator import narrate_cm, narrate, get_narration, set_narration_options


@narrate("So I started to 'nf1'...")
def f1():
    f2()


@narrate("...which occasioned me to 'nf2'")
def f2():
    with narrate_cm("during which I started a narration context..."):
        f3()


@narrate("...and that led me to finally 'nf3'")
def f3():
    raise Exception("oops")


if __name__ == "__main__":
    set_narration_options(verbose=True)
    try:
        f1()
    except:
        for l in get_narration():
            print(l)
Ejemplo n.º 25
0
from errator import narrate_cm, narrate, get_narration


@narrate("So I started to 'f1'...")
def f1():
    f2()


@narrate("...which occasioned me to 'f2'")
def f2():
    with narrate_cm("during which I started a narration context..."):
        f3()


@narrate("...and that led me to finally 'f3'")
def f3():
    raise Exception("oops")


if __name__ == "__main__":
    try:
        f1()
    except:
        for l in get_narration(verbose=True):
            print(l)