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