Avoid using "raise" to reraise with modified exception

The code changes the exception and reraises it.
This commit changes the code to use the same way as
excutils.save_and_reraise_exception does to ensure
the exception context.

This is the last patch of reraise clean up series.

Closes-Bug: #1279813
Change-Id: I8787dcbdc8321f75964de26e97cae395707aafc2
This commit is contained in:
Akihiro Motoki 2014-02-13 02:51:45 +09:00 committed by Gerrit Code Review
parent 2964b8483a
commit 6b13ee0c3b

View File

@ -17,7 +17,10 @@
Utility methods for working with WSGI servers redux
"""
import sys
import netaddr
import six
import webob.dec
import webob.exc
@ -103,11 +106,12 @@ def Resource(controller, faults=None, deserializers=None, serializers=None):
kwargs = {'body': body, 'content_type': content_type}
raise mapped_exc(**kwargs)
except webob.exc.HTTPException as e:
type_, value, tb = sys.exc_info()
LOG.exception(_('%s failed'), action)
translate(e, language)
e.body = serializer.serialize({'NeutronError': e})
e.content_type = content_type
raise
value.body = serializer.serialize({'NeutronError': e})
value.content_type = content_type
six.reraise(type_, value, tb)
except NotImplementedError as e:
e = translate(e, language)
# NOTE(armando-migliaccio): from a client standpoint