summaryrefslogtreecommitdiff
path: root/src/mailman/rest/validator.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/mailman/rest/validator.py')
-rw-r--r--src/mailman/rest/validator.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/mailman/rest/validator.py b/src/mailman/rest/validator.py
index c59bc53d8..2d178226f 100644
--- a/src/mailman/rest/validator.py
+++ b/src/mailman/rest/validator.py
@@ -48,9 +48,13 @@ class enum_validator:
self._enum_class = enum_class
def __call__(self, enum_value):
- # This will raise a ValueError if the enum value is unknown. Let that
- # percolate up.
- return self._enum_class[enum_value]
+ # This will raise a KeyError if the enum value is unknown. The
+ # Validator API requires turning this into a ValueError.
+ try:
+ return self._enum_class[enum_value]
+ except KeyError as exception:
+ # Retain the error message.
+ raise ValueError(exception.message)
def subscriber_validator(subscriber):