diff options
| author | Barry Warsaw | 2013-08-27 22:14:44 -0400 |
|---|---|---|
| committer | Barry Warsaw | 2013-08-27 22:14:44 -0400 |
| commit | 26c3adb4f457cfc41751aa0203efbb3582adeb2d (patch) | |
| tree | 90973bea29478795792cf36feec8cab6d4525d61 /src/mailman/rest/validator.py | |
| parent | c175a7036261383b8e3440b5995886674f3f4d7c (diff) | |
| parent | 0120c079ed8c9a9b0b1bc5d8341ac2ec1a8638d3 (diff) | |
| download | mailman-26c3adb4f457cfc41751aa0203efbb3582adeb2d.tar.gz mailman-26c3adb4f457cfc41751aa0203efbb3582adeb2d.tar.zst mailman-26c3adb4f457cfc41751aa0203efbb3582adeb2d.zip | |
Diffstat (limited to 'src/mailman/rest/validator.py')
| -rw-r--r-- | src/mailman/rest/validator.py | 10 |
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): |
