Beispiel #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()
Beispiel #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()
Beispiel #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("")
Beispiel #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
Beispiel #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
Beispiel #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
Beispiel #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
Beispiel #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
Beispiel #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
Beispiel #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
Beispiel #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
Beispiel #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
Beispiel #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
Beispiel #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
Beispiel #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
Beispiel #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
Beispiel #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
Beispiel #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
Beispiel #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
Beispiel #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
Beispiel #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
Beispiel #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()
Beispiel #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()
Beispiel #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)
Beispiel #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)