From 5a61fca55aaabf08585ad64542b3da789415662a Mon Sep 17 00:00:00 2001 From: Wiebe Cazemier Date: Mon, 20 May 2024 11:59:44 +1000 Subject: [PATCH] Use string of reason code in connack failure --- mqttpacket.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mqttpacket.cpp b/mqttpacket.cpp index 16f9232..b78a9d3 100644 --- a/mqttpacket.cpp +++ b/mqttpacket.cpp @@ -1135,7 +1135,8 @@ void MqttPacket::handleConnAck() if (data.reasonCode != ReasonCodes::Success) { - throw std::runtime_error(formatString("Client '%s' connection failed. Reason code: %d", sender->repr().c_str(), data.reasonCode)); + const std::string err = "Client '" + sender->repr() + "' connection failed. Reason: " + reasonCodeToString(data.reasonCode) ; + throw std::runtime_error(err); } if (!settings->allowUnsafeClientidChars && containsDangerousCharacters(data.assigned_client_id))