From: Akihiro Motoki Date: Wed, 12 Feb 2014 17:51:45 +0000 (+0900) Subject: Avoid using "raise" to reraise with modified exception X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=f55142e907f18ee2a54f00b3bfc964b250c286d1;p=openstack-build%2Fneutron-build.git 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 --- diff --git a/neutron/api/v2/resource.py b/neutron/api/v2/resource.py index fb139b2ac..59f4dc550 100644 --- a/neutron/api/v2/resource.py +++ b/neutron/api/v2/resource.py @@ -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