Merge "Catch specific exception when validating time zone"
This commit is contained in:
commit
7df6a7d1d6
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user