diff options
| author | wanghong <w.wanghong@huawei.com> | 2014-09-24 11:04:41 +0800 |
|---|---|---|
| committer | wanghong <w.wanghong@huawei.com> | 2014-09-24 11:04:41 +0800 |
| commit | 7029cf37e268a789a65bab3b9a16e4491854106e (patch) | |
| tree | c7d3f4e5c7172af4fbf102758e3e3c4937e0ceff /openstackclient | |
| parent | ffe976ce3edf2e4dc5dd50247a182ca690b4fdd9 (diff) | |
| download | python-openstackclient-7029cf37e268a789a65bab3b9a16e4491854106e.tar.gz | |
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
Diffstat (limited to 'openstackclient')
| -rw-r--r-- | openstackclient/common/utils.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/openstackclient/common/utils.py b/openstackclient/common/utils.py index 5c5466df..818f8d47 100644 --- a/openstackclient/common/utils.py +++ b/openstackclient/common/utils.py @@ -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: |
