[ create a new paste ] login | about

Link: http://codepad.org/ivJe0q9B    [ raw code | output | fork ]

Python, pasted on Oct 5:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
def throw_exc():
    bla

try:
    throw_exc()
except Exception, e:
    import traceback, os.path
    top = traceback.extract_stack()[-1]
    print ", ".join([type(e).__name__, os.path.basename(top[0]), str(top[1])])

try:
    throw_exc()
except Exception, e:
    import traceback, sys, os.path
    top = traceback.extract_tb(sys.exc_info()[2])[-1]
    print ", ".join([type(e).__name__, os.path.basename(top[0]), str(top[1])])


Output:
1
2
NameError, t.py, 8
NameError, t.py, 2


Create a new paste based on this one


Comments: