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):
|
def _fromFile(self, fd):
|
||||||
lines = [i.rstrip() for i in fd.readlines()]
|
lines = [i.rstrip() for i in fd.readlines()]
|
||||||
current = Record()
|
current = Record()
|
||||||
|
cl = 0
|
||||||
|
|
||||||
for i in lines:
|
for i in lines:
|
||||||
|
cl += 1
|
||||||
ind = i[0:2] == ' '
|
ind = i[0:2] == ' '
|
||||||
|
|
||||||
if ind:
|
if ind:
|
||||||
@ -49,13 +51,12 @@ class RecordCollection():
|
|||||||
try:
|
try:
|
||||||
current[spl[0]] = spl[1]
|
current[spl[0]] = spl[1]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
# TODO: maybe add line numbers?
|
raise FileParsingError(f"error parsing '{i}' @ {cl}")
|
||||||
raise FileParsingError(f"error parsing '{i}'")
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
if i[-1] != ":":
|
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]
|
name = i.split(' ')[1][0:-1]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
current = Record()
|
current = Record()
|
||||||
@ -74,7 +75,7 @@ class RecordCollection():
|
|||||||
|
|
||||||
# TODO: add more precise error checking
|
# TODO: add more precise error checking
|
||||||
if not len(inherit) == len(inherit_order):
|
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(
|
for j, k in zip(
|
||||||
inherit,
|
inherit,
|
||||||
|
Loading…
Reference in New Issue
Block a user