diff --git a/aws/sqs/src/main/scala/com/commercetools/queue/aws/sqs/package.scala b/aws/sqs/src/main/scala/com/commercetools/queue/aws/sqs/package.scala index aca1c54..153a0ed 100644 --- a/aws/sqs/src/main/scala/com/commercetools/queue/aws/sqs/package.scala +++ b/aws/sqs/src/main/scala/com/commercetools/queue/aws/sqs/package.scala @@ -32,9 +32,15 @@ package object sqs { new CannotPushException(queueName, makeQueueException(t, queueName)) def makePullQueueException(t: Throwable, queueName: String): QueueException = - new CannotPullException(queueName, makeQueueException(t, queueName)) + t match { + case t: QueueException => t + case _ => new CannotPullException(queueName, makeQueueException(t, queueName)) + } def makeMessageException(t: Throwable, queueName: String, msgId: String, action: Action): QueueException = - new MessageException(msgId = msgId, action = action, inner = makeQueueException(t, queueName)) + t match { + case t: QueueException => t + case _ => new MessageException(msgId = msgId, action = action, inner = makeQueueException(t, queueName)) + } } diff --git a/azure/service-bus/src/main/scala/com/commercetools/queue/azure/servicebus/package.scala b/azure/service-bus/src/main/scala/com/commercetools/queue/azure/servicebus/package.scala index d140c17..993697a 100644 --- a/azure/service-bus/src/main/scala/com/commercetools/queue/azure/servicebus/package.scala +++ b/azure/service-bus/src/main/scala/com/commercetools/queue/azure/servicebus/package.scala @@ -33,9 +33,15 @@ package object servicebus { new CannotPushException(queueName, makeQueueException(t, queueName)) def makePullQueueException(t: Throwable, queueName: String): QueueException = - new CannotPullException(queueName, makeQueueException(t, queueName)) + t match { + case t: QueueException => t + case _ => new CannotPullException(queueName, makeQueueException(t, queueName)) + } def makeMessageException(t: Throwable, queueName: String, msgId: String, action: Action): QueueException = - new MessageException(msgId = msgId, action = action, inner = makeQueueException(t, queueName)) + t match { + case t: QueueException => t + case _ => new MessageException(msgId = msgId, action = action, inner = makeQueueException(t, queueName)) + } }