add line numbers to syntax error messages
This commit is contained in:
parent
41565af01f
commit
c6e5bd376c
|
@ -40,8 +40,10 @@ class RecordCollection():
|
|||
def _fromFile(self, fd):
|
||||
lines = [i.rstrip() for i in fd.readlines()]
|
||||
current = Record()
|
||||
cl = 0
|
||||
|
||||
for i in lines:
|
||||
cl += 1
|
||||
ind = i[0:2] == ' '
|
||||
|
||||
if ind:
|
||||
|
@ -49,13 +51,12 @@ class RecordCollection():
|
|||
try:
|
||||
current[spl[0]] = spl[1]
|
||||
except IndexError:
|
||||
# TODO: maybe add line numbers?
|
||||
raise FileParsingError(f"error parsing '{i}'")
|
||||
raise FileParsingError(f"error parsing '{i}' @ {cl}")
|
||||
|
||||
else:
|
||||
try:
|
||||
if i[-1] != ":":
|
||||
raise FileParsingError(f"colon must be on last character of '{i}'")
|
||||
raise FileParsingError(f"colon must be on last character of '{i}' @ {cl}")
|
||||
name = i.split(' ')[1][0:-1]
|
||||
except IndexError:
|
||||
current = Record()
|
||||
|
@ -74,7 +75,7 @@ class RecordCollection():
|
|||
|
||||
# TODO: add more precise error checking
|
||||
if not len(inherit) == len(inherit_order):
|
||||
raise FileParsingError("len(inherit) != len(inherit_order)")
|
||||
raise FileParsingError("len(inherit) != len(inherit_order) @ {cl}")
|
||||
|
||||
for j, k in zip(
|
||||
inherit,
|
||||
|
|
Loading…
Reference in New Issue