Skip to content

Commit 33fa282

Browse files
authored
DataValidation: Show the game name that has validation errors (#158)
* identify the game name when showing validation errors * use the provided cls since this only runs in assert
1 parent 1f41d5a commit 33fa282

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/DataValidation.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -445,10 +445,12 @@ def runPreFillDataValidation(world: World, multiworld: MultiWorld):
445445
except ValidationError as e: validation_errors.append(e)
446446

447447
if validation_errors:
448+
heading = f"ValidationError(s) for pre_fill of {world.game}:";
448449
newline = "\n"
449-
raise Exception(f"\nValidationError(s) for pre_fill of player {world.player}: \n\n{newline.join([' - ' + str(validation_error) for validation_error in validation_errors])}\n\n")
450+
raise Exception(f"\n\n{heading} \n\n{newline.join([' - ' + str(validation_error) for validation_error in validation_errors])}\n\n")
451+
450452
# Called during stage_assert_generate
451-
def runGenerationDataValidation() -> None:
453+
def runGenerationDataValidation(cls) -> None:
452454
validation_errors = []
453455

454456
# check that requires have correct item names in locations and regions
@@ -502,5 +504,8 @@ def runGenerationDataValidation() -> None:
502504
# check for regions that are set as non-starting regions and have no connectors to them (so are unreachable)
503505
try: DataValidation.checkForNonStartingRegionsThatAreUnreachable()
504506
except ValidationError as e: validation_errors.append(e)
507+
505508
if len(validation_errors) > 0:
506-
raise Exception("\nValidationError(s): \n\n%s\n\n" % ("\n".join([' - ' + str(validation_error) for validation_error in validation_errors])))
509+
heading = f"ValidationError(s) in {cls.game}:";
510+
511+
raise Exception("\n\n%s \n\n%s\n\n" % (heading, "\n".join([' - ' + str(validation_error) for validation_error in validation_errors])))

src/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def interpret_slot_data(self, slot_data: dict[str, any]):
9090

9191
@classmethod
9292
def stage_assert_generate(cls, multiworld) -> None:
93-
runGenerationDataValidation()
93+
runGenerationDataValidation(cls)
9494

9595

9696
def create_regions(self):

0 commit comments

Comments
 (0)