Adding more descriptive error message

Keystone Trusts API sends non descriptive error message for requests with
invalid trust id.
The error message only contains invalid_trust_id  instead of printing:
"Could not find trust: invalid_trust_id"
Setting kwarg "trust_id" in the exception.

Closes-Bug: #1305272
Change-Id: I35cab35ab90cf66ce7124dea142013bec9eefda9
This commit is contained in:
Priti Desai 2014-04-08 23:02:59 +00:00 committed by Morgan Fainberg
parent a9d4e59e86
commit da4d4a1035
1 changed files with 4 additions and 4 deletions

View File

@ -73,7 +73,7 @@ class TrustV3(controller.V3Controller):
user_id = self._get_user_id(context)
trust = self.trust_api.get_trust(trust_id)
if not trust:
raise exception.TrustNotFound(trust_id)
raise exception.TrustNotFound(trust_id=trust_id)
_trustor_trustee_only(trust, user_id)
self._fill_in_roles(context, trust,
self.assignment_api.list_roles())
@ -214,7 +214,7 @@ class TrustV3(controller.V3Controller):
def delete_trust(self, context, trust_id):
trust = self.trust_api.get_trust(trust_id)
if not trust:
raise exception.TrustNotFound(trust_id)
raise exception.TrustNotFound(trust_id=trust_id)
user_id = self._get_user_id(context)
_admin_trustor_only(context, trust, user_id)
@ -226,7 +226,7 @@ class TrustV3(controller.V3Controller):
def list_roles_for_trust(self, context, trust_id):
trust = self.get_trust(context, trust_id)['trust']
if not trust:
raise exception.TrustNotFound(trust_id)
raise exception.TrustNotFound(trust_id=trust_id)
user_id = self._get_user_id(context)
_trustor_trustee_only(trust, user_id)
return {'roles': trust['roles'],
@ -237,7 +237,7 @@ class TrustV3(controller.V3Controller):
"""Checks if a role has been assigned to a trust."""
trust = self.trust_api.get_trust(trust_id)
if not trust:
raise exception.TrustNotFound(trust_id)
raise exception.TrustNotFound(trust_id=trust_id)
user_id = self._get_user_id(context)
_trustor_trustee_only(trust, user_id)
if not any(role['id'] == role_id for role in trust['roles']):