From 55b37d5e33f322077303a895d3453320b3895f11 Mon Sep 17 00:00:00 2001 From: Hidekazu Nakamura Date: Fri, 6 Nov 2015 00:47:38 +0900 Subject: Don't mask authorization errors Project show with name argument returns 'Could not find resource' error when the user is not authorized. It should report the authorization error instead. This patch makes that change. Change-Id: Iac3521f8a411060b0ec9ef46c8f0e1f3551e56ae Closes-Bug: #1511625 --- openstackclient/common/utils.py | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) (limited to 'openstackclient/common/utils.py') diff --git a/openstackclient/common/utils.py b/openstackclient/common/utils.py index c6ed6a71..daa65c25 100644 --- a/openstackclient/common/utils.py +++ b/openstackclient/common/utils.py @@ -100,22 +100,15 @@ def find_resource(manager, name_or_id, **kwargs): else: pass - try: - for resource in manager.list(): - # short circuit and return the first match - if (resource.get('id') == name_or_id or - resource.get('name') == name_or_id): - return resource - else: - # we found no match, keep going to bomb out - pass - except Exception: - # in case the list fails for some reason - pass - - # if we hit here, we've failed, report back this error: - msg = "Could not find resource %s" % name_or_id - raise exceptions.CommandError(msg) + for resource in manager.list(): + # short circuit and return the first match + if (resource.get('id') == name_or_id or + resource.get('name') == name_or_id): + return resource + else: + # we found no match, report back this error: + msg = "Could not find resource %s" % name_or_id + raise exceptions.CommandError(msg) def format_dict(data): -- cgit v1.2.1