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
This commit is contained in:
parent
ffe976ce3e
commit
7029cf37e2
@ -33,8 +33,15 @@ def find_resource(manager, name_or_id):
|
||||
try:
|
||||
if isinstance(name_or_id, int) or name_or_id.isdigit():
|
||||
return manager.get(int(name_or_id))
|
||||
except exceptions.NotFound:
|
||||
pass
|
||||
# FIXME(dtroyer): The exception to catch here is dependent on which
|
||||
# client library the manager passed in belongs to.
|
||||
# Eventually this should be pulled from a common set
|
||||
# of client exceptions.
|
||||
except Exception as ex:
|
||||
if type(ex).__name__ == 'NotFound':
|
||||
pass
|
||||
else:
|
||||
raise
|
||||
|
||||
# Try directly using the passed value
|
||||
try:
|
||||
|
Loading…
Reference in New Issue
Block a user