Log exception info when objects fail to init

This will now log an error with a traceback
indicating what caused the ProgrammingError exception
instead of hiding the cause of the failure.

Change-Id: I82e4d2c6961c6b456d129d8a0afd5972ff53785f
This commit is contained in:
Eric Harney 2019-08-19 14:04:21 -04:00
parent 8a4dbf3eef
commit ec70a02ddf
1 changed files with 2 additions and 1 deletions

View File

@ -279,9 +279,10 @@ class CinderPersistentObject(object):
# registration.
try:
cls.model = db.get_model_for_versioned_object(cls)
except (ImportError, AttributeError):
except (ImportError, AttributeError) as e:
msg = _("Couldn't find ORM model for Persistent Versioned "
"Object %s.") % cls.obj_name()
LOG.exception("Failed to initialize object.")
raise exception.ProgrammingError(reason=msg)
@contextlib.contextmanager