mark line number in traceback

This commit is contained in:
Stanislav Seletskiy 2015-10-20 16:09:02 +06:00
parent 00e3a877d9
commit 3accb5cb44

View File

@ -8,6 +8,7 @@ from functools import wraps
import os import os
import platform import platform
import traceback import traceback
import sys
import vim import vim
from contextlib import contextmanager from contextlib import contextmanager
@ -68,11 +69,19 @@ Following is the full stack trace:
msg += traceback.format_exc() msg += traceback.format_exc()
if hasattr(e, 'code'): if hasattr(e, 'code'):
_, _, tb = sys.exc_info()
tb_top = traceback.extract_tb(tb)[-1]
msg += "\nFollowing is the full executed code:\n" msg += "\nFollowing is the full executed code:\n"
lines = e.code.split("\n") lines = e.code.split("\n")
number = 1 number = 1
for line in lines: for line in lines:
msg += str(number) + ": " + line + "\n" msg += str(number).rjust(3)
prefix = ""
if line != "":
prefix = " "
if tb_top[1] == number:
prefix = " > "
msg += prefix + line + "\n"
number += 1 number += 1
# Vim sends no WinLeave msg here. # Vim sends no WinLeave msg here.