diff options
| author | Russell Bryant <rbryant@redhat.com> | 2012-04-28 23:14:49 -0400 |
|---|---|---|
| committer | Russell Bryant <rbryant@redhat.com> | 2012-04-28 23:14:49 -0400 |
| commit | 212b3716c92a138b08ef97d8bb609e427d622d45 (patch) | |
| tree | 0f38cb81b787cfd43487a9f42201010949849406 /openstack/common | |
| parent | b86e37e15e2fbb507ae66c2f57a5e0660fdd1a7f (diff) | |
| download | oslo-212b3716c92a138b08ef97d8bb609e427d622d45.tar.gz oslo-212b3716c92a138b08ef97d8bb609e427d622d45.tar.xz oslo-212b3716c92a138b08ef97d8bb609e427d622d45.zip | |
Update exception from importutils.import_class().
Update the message included in the exception from
importutils.import_class() to include what the inner exception was.
This is quite helpful as the real error may not have been that the class
was not found. It may have failed to import the module that contains
that class, and it's nice to know that and why that happened.
Change-Id: I085864d230b46adce8921e362f058f9421a5a674
Diffstat (limited to 'openstack/common')
| -rw-r--r-- | openstack/common/importutils.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/openstack/common/importutils.py b/openstack/common/importutils.py index b23d6d4..48b7af1 100644 --- a/openstack/common/importutils.py +++ b/openstack/common/importutils.py @@ -30,8 +30,9 @@ def import_class(import_str): try: __import__(mod_str) return getattr(sys.modules[mod_str], class_str) - except (ImportError, ValueError, AttributeError): - raise exception.NotFound('Class %s cannot be found' % class_str) + except (ImportError, ValueError, AttributeError), exc: + raise exception.NotFound('Class %s cannot be found (%s)' % + (class_str, str(exc))) def import_object(import_str, *args, **kwargs): |
