Skip to content

Commit

Permalink
Include slightly more detail in this validation message
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterJCLaw committed Nov 17, 2024
1 parent 4e54921 commit 9c0b0b2
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions scoring/score.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,12 @@ def validate(self, other_data):
totals = collections.Counter()
for district in self._districts.values():
totals += district['pallet_counts']
if any(x > TOKENS_PER_ZONE for x in totals.values()):
bad_totals = [x for x, y in totals.items() if y > TOKENS_PER_ZONE]
if bad_totals:
raise InvalidScoresheetException(
f"Too many pallets of some kinds specified, must be no more "
f"than {TOKENS_PER_ZONE} of each type.\n"
f"{totals!r}",
f"Too many {join_and(repr(x) for x in bad_totals)} pallets "
f"specified, must be no more than {TOKENS_PER_ZONE} of each type.\n"
f"Totals: {totals!r}",
code='too_many_pallets',
)

Expand Down

0 comments on commit 9c0b0b2

Please sign in to comment.