add a little bit of error checking

This commit is contained in:
randomuser 2021-11-22 22:44:36 -06:00
parent 89e03122f7
commit 55e8706f80
1 changed files with 11 additions and 2 deletions

View File

@ -45,6 +45,7 @@ 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}'") raise FileParsingError(f"error parsing '{i}'")
else: else:
@ -61,9 +62,17 @@ class RecordCollection():
for i in self.objects: for i in self.objects:
current = self.objects[i] current = self.objects[i]
try: try:
for j, k in zip( inherit = current['inherit'].split(' ')
current['inherit'].split(' '), inherit_order = \
[int(i) for i in current['inherit_order'].split(' ')] [int(i) for i in current['inherit_order'].split(' ')]
# TODO: add more precise error checking
if not len(inherit) == len(inherit_order):
raise FileParsingError("len(inherit) != len(inherit_order)")
for j, k in zip(
inherit,
inherit_order
): ):
current.parents[j] = self.objects[j] current.parents[j] = self.objects[j]