Merge "Catch specific exception when validating time zone"

This commit is contained in:
Zuul 2024-03-15 07:58:37 +00:00 committed by Gerrit Code Review
commit 7df6a7d1d6

View File

@ -31,6 +31,7 @@ from oslo_utils import uuidutils
import pecan
from pecan import rest
import pytz
import pytz.exceptions
from stevedore import extension
from urllib import parse as urlparse
import wsme
@ -177,7 +178,7 @@ class AlarmTimeConstraint(base.Base):
if tc.timezone:
try:
pytz.timezone(tc.timezone)
except Exception:
except pytz.exceptions.UnknownTimeZoneError:
raise base.ClientSideError(_("Timezone %s is not valid")
% tc.timezone)
return tc