Raise old exception instance instead of new one.

Updates the Nova conductor API's ExceptionHelper class so that
it raises the previous exception instance instead of constructing
a new exception class based on the old one's message.

The motivation for this change is to enable testing of NovaException
message formatting. Previously this function would always construct
a new NovaException which had the incorrect (none) kwargs specified
to properly format the message. The exception would get thrown... but
it would cause extra LOG.error messages to appear in the log file due
to the formatting errors.

This commit works around the issue by raising the previous Exception
directly. From 'pydoc raise':

  If the first object is an instance, the type of the exception is the
  class of the instance, the instance itself is the value, and the
  second object must be ``None``.

Change-Id: I1dddc9e1e7e3d5f970baa9a34b709c943820295e
This commit is contained in:
Dan Prince 2012-12-18 10:00:30 -05:00
parent 65d9f80b5b
commit f8d2f8689a

View File

@ -55,7 +55,7 @@ class ExceptionHelper(object):
try:
return func(*args, **kwargs)
except rpc_common.ClientException, e:
raise e._exc_info
raise (e._exc_info[1], None, e._exc_info[2])
return wrapper