You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, new to the project, and loving where it's going.
I thought about opening a PR to start... but maybe some context first might make more sense. When debugging my app, I ran into a situation where a timeout would cause paho to stop sending all messages. I was catching and logging the errors, but missed the subtle difference between the MqttError and MqttCodeError types behind the scenes.
For reasons still somewhat unknown, the reason code was being set to an integer (not a mqtt.ReasonCode) and the subtle [Code: 4] added to the __str__() had slipped by. Once I took a deeper look at what was happening, I saw the extra information, as well as a helper method in paho's source code: https://github.com/eclipse/paho.mqtt.python/blob/master/src/paho/mqtt/client.py#L183
The simple complaint here, is that [Code: {}] is a small addition to an error message, easy to miss, and a not-very-idiomatic error number, when it could instead be an english error message in instances where the rc value is actually an integer.
using Paho's error_message handler or using their builtin methods, we could change the __str__() method in MqttCodeError to look something a little like this:
But for such a simple change... I figured it'd be better to ask if there was a reason it was setup this way, or if I'm touching something that hasn't been considered in a while. Maybe my versions are worth considering? paho-mqtt-1.5.1 and asyncio_mqtt-0.9.1
If this sounds like a useful change, I'd be more than willing to open up a simple PR... otherwise I'd be interested in learning why the integer codes are preferred to Paho's internal error messages.
The text was updated successfully, but these errors were encountered:
Do you also want to see the additional {super().__str__()} call in there? In my use case, 100% of the time, that will end up saying Could not publish message
Hi, new to the project, and loving where it's going.
I thought about opening a PR to start... but maybe some context first might make more sense. When debugging my app, I ran into a situation where a timeout would cause paho to stop sending all messages. I was catching and logging the errors, but missed the subtle difference between the
MqttError
andMqttCodeError
types behind the scenes.For reasons still somewhat unknown, the reason code was being set to an integer (not a
mqtt.ReasonCode
) and the subtle[Code: 4]
added to the__str__()
had slipped by. Once I took a deeper look at what was happening, I saw the extra information, as well as a helper method in paho's source code: https://github.com/eclipse/paho.mqtt.python/blob/master/src/paho/mqtt/client.py#L183The simple complaint here, is that
[Code: {}]
is a small addition to an error message, easy to miss, and a not-very-idiomatic error number, when it could instead be an english error message in instances where therc
value is actually an integer.using Paho's
error_message
handler or using their builtin methods, we could change the__str__()
method inMqttCodeError
to look something a little like this:But for such a simple change... I figured it'd be better to ask if there was a reason it was setup this way, or if I'm touching something that hasn't been considered in a while. Maybe my versions are worth considering?
paho-mqtt-1.5.1
andasyncio_mqtt-0.9.1
If this sounds like a useful change, I'd be more than willing to open up a simple PR... otherwise I'd be interested in learning why the integer codes are preferred to Paho's internal error messages.
The text was updated successfully, but these errors were encountered: