Skip to content

Commit

Permalink
Backport invalid value logging in ChoiceAttribute from #2624 to 8.0.x
Browse files Browse the repository at this point in the history
  • Loading branch information
dgw committed Oct 13, 2024
1 parent 6ccd615 commit 107e57c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions sopel/config/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,10 @@ def parse(self, value):
if value in self.choices:
return value
else:
raise ValueError('Value must be in {}'.format(self.choices))
raise ValueError(
'{!r} is not one of the valid choices: {}'
.format(value, ', '.join(self.choices))
)

def serialize(self, value):
"""Make sure ``value`` is valid and safe to write in the config file.
Expand All @@ -662,7 +665,10 @@ def serialize(self, value):
if value in self.choices:
return value
else:
raise ValueError('Value must be in {}'.format(self.choices))
raise ValueError(
'{!r} is not one of the valid choices: {}'
.format(value, ', '.join(self.choices))
)


class FilenameAttribute(BaseValidated):
Expand Down

0 comments on commit 107e57c

Please sign in to comment.