Skip to content

Commit 7029cf3

Browse files
committed
utils.find_resource does not catch right exception
Currently, utils.find_resource catch NotFound exception defined in openstackclient. However, different client libraries raise different exceptions defined in thire own library. Change-Id: Idc40428e30e59f71dbdbfa0555c0066fddc441c2 Closes-Bug: #1371924
1 parent ffe976c commit 7029cf3

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

‎openstackclient/common/utils.py‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,15 @@ def find_resource(manager, name_or_id):
3333
try:
3434
if isinstance(name_or_id, int) or name_or_id.isdigit():
3535
return manager.get(int(name_or_id))
36-
except exceptions.NotFound:
37-
pass
36+
# FIXME(dtroyer): The exception to catch here is dependent on which
37+
# client library the manager passed in belongs to.
38+
# Eventually this should be pulled from a common set
39+
# of client exceptions.
40+
except Exception as ex:
41+
if type(ex).__name__ == 'NotFound':
42+
pass
43+
else:
44+
raise
3845

3946
# Try directly using the passed value
4047
try:

0 commit comments

Comments
 (0)