Policy exception

When fail to query policy information by policy_id(in
policy\backends\sql.py Policy::_get_policy function), it will raise
'exception.PolicyNotFound(policy_id=policy_id)', the deleted code is
redundant if all it does is catch the same exception
and then re-throw it.


Change-Id: I3d4f7175764798449a3efe787af58dc2ea99fc1f
This commit is contained in:
chenaidong1 2017-09-06 17:29:49 +08:00
parent fe87d28422
commit bdf47dd491
1 changed files with 3 additions and 12 deletions

View File

@ -46,18 +46,12 @@ class Manager(manager.Manager):
return ref
def get_policy(self, policy_id):
try:
return self.driver.get_policy(policy_id)
except exception.NotFound:
raise exception.PolicyNotFound(policy_id=policy_id)
return self.driver.get_policy(policy_id)
def update_policy(self, policy_id, policy, initiator=None):
if 'id' in policy and policy_id != policy['id']:
raise exception.ValidationError('Cannot change policy ID')
try:
ref = self.driver.update_policy(policy_id, policy)
except exception.NotFound:
raise exception.PolicyNotFound(policy_id=policy_id)
ref = self.driver.update_policy(policy_id, policy)
notifications.Audit.updated(self._POLICY, policy_id, initiator)
return ref
@ -69,9 +63,6 @@ class Manager(manager.Manager):
return self.driver.list_policies()
def delete_policy(self, policy_id, initiator=None):
try:
ret = self.driver.delete_policy(policy_id)
except exception.NotFound:
raise exception.PolicyNotFound(policy_id=policy_id)
ret = self.driver.delete_policy(policy_id)
notifications.Audit.deleted(self._POLICY, policy_id, initiator)
return ret