diff options
| author | Russell Bryant <rbryant@redhat.com> | 2012-06-19 17:08:35 -0400 |
|---|---|---|
| committer | Russell Bryant <rbryant@redhat.com> | 2012-06-19 17:11:15 -0400 |
| commit | 8c74b37f5bdf1141b8c3724c8df460e6562d1985 (patch) | |
| tree | b1ee5aedee690a2f13b02d3371baed1bbdac6271 /openstack | |
| parent | e31b5ceb5592026c23ace2608c0af9f5487d1f07 (diff) | |
| download | oslo-8c74b37f5bdf1141b8c3724c8df460e6562d1985.tar.gz oslo-8c74b37f5bdf1141b8c3724c8df460e6562d1985.tar.xz oslo-8c74b37f5bdf1141b8c3724c8df460e6562d1985.zip | |
Improve exception from importutils.import_class().
The ImportError raised by import_class() attempted to tell you what the
original error was by just doing str() on the original exception.
Sometimes that's helpful, but sometimes a full traceback is needed.
This patch includes a traceback for debugging purposes.
Change-Id: I00cefb9ebf9d6a71ef491204d81765e30e7941f6
Diffstat (limited to 'openstack')
| -rw-r--r-- | openstack/common/importutils.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/openstack/common/importutils.py b/openstack/common/importutils.py index 67d94ad..2fbb029 100644 --- a/openstack/common/importutils.py +++ b/openstack/common/importutils.py @@ -20,6 +20,7 @@ Import related utilities and helper functions. """ import sys +import traceback def import_class(import_str): @@ -30,7 +31,8 @@ def import_class(import_str): return getattr(sys.modules[mod_str], class_str) except (ImportError, ValueError, AttributeError), exc: raise ImportError('Class %s cannot be found (%s)' % - (class_str, str(exc))) + (class_str, + traceback.format_exception(*sys.exc_info()))) def import_object(import_str, *args, **kwargs): |
