Merge "Fix for raising excepton from kombu"

This commit is contained in:
Jenkins 2016-09-23 07:58:13 +00:00 committed by Gerrit Code Review
commit 61f4de482d
4 changed files with 12 additions and 8 deletions

View File

@ -135,8 +135,9 @@ class KombuRPCServer(rpc_base.RPCServer, kombu_base.Base):
try:
return self._on_message(request, message)
except Exception as e:
# Wrap exception into another exception for compability with oslo.
self.publish_message(
e,
exc.KombuException(e),
message.properties['reply_to'],
message.properties['correlation_id'],
res_type='error'

View File

@ -311,7 +311,7 @@ def wrap_messaging_exception(method):
except exc.MistralException:
raise
except (client.RemoteError, Exception) as e:
except (client.RemoteError, exc.KombuException, Exception) as e:
if hasattr(e, 'exc_type') and hasattr(exc, e.exc_type):
exc_cls = getattr(exc, e.exc_type)
raise exc_cls(e.value)

View File

@ -192,3 +192,11 @@ class NotAllowedException(MistralException):
class UnauthorizedException(MistralException):
http_code = 401
message = "Unauthorized"
class KombuException(Exception):
def __init__(self, e):
super(KombuException, self).__init__(e)
self.exc_type = e.__class__.__name__
self.value = str(e)

View File

@ -160,12 +160,7 @@ class KombuServerTestCase(base.KombuTestCase):
self.server._on_message_safe(None, message)
self.assertEqual(message.ack.call_count, 1)
publish_message.assert_called_once_with(
test_exception,
reply_to,
correlation_id,
res_type='error'
)
self.assertEqual(publish_message.call_count, 1)
@mock.patch.object(
kombu_server.KombuRPCServer,