Merge "Fix for raising excepton from kombu"
This commit is contained in:
commit
61f4de482d
|
@ -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'
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue