From e9a7e32bf5d8b2818719a9a999bb6b7f8ec83464 Mon Sep 17 00:00:00 2001 From: Mark van Renswoude Date: Sun, 18 Jul 2021 13:52:49 +0200 Subject: [PATCH] Slightly improved logging to fix #28 Logging the body is not worth it at the moment, as the original issue regarding corrupt body contents has been fixed already --- Tapeti/Connection/TapetiConsumer.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Tapeti/Connection/TapetiConsumer.cs b/Tapeti/Connection/TapetiConsumer.cs index 6d97155..014fb20 100644 --- a/Tapeti/Connection/TapetiConsumer.cs +++ b/Tapeti/Connection/TapetiConsumer.cs @@ -44,9 +44,16 @@ namespace Tapeti.Connection object message = null; try { - message = messageSerializer.Deserialize(body, properties); - if (message == null) - throw new ArgumentException("Message body could not be deserialized into a message object", nameof(body)); + try + { + message = messageSerializer.Deserialize(body, properties); + if (message == null) + throw new ArgumentException($"Message body for routing key '{routingKey}' could not be deserialized into a message object", nameof(body)); + } + catch (Exception e) + { + throw new ArgumentException($"Message body for routing key '{routingKey}' could not be deserialized into a message object: {e.Message}", nameof(body), e); + } return await DispatchMessage(message, new MessageContextData {