AdvancedClimateSystems / uModbus

Python implementation of the Modbus protocol.
Mozilla Public License 2.0
211 stars 81 forks source link

Pass a partially received response in the ValueError exception. #113

Open acolomb opened 3 years ago

acolomb commented 3 years ago

Allow better debugging when an incomplete response was received or timed out. The already received part (empty on timeout) is passed as the first and only argument in the ValueError exception, accessible as e.args[0] in a handler.

I find the choice of ValueError exception kind of confusing for this type of error, but anything else would break compatibility. So I opted to just add the (partial) response verbatim as an argument. If it is empty, a TimeoutError or similar might be easier to understand?

coveralls commented 3 years ago

Coverage Status

Coverage decreased (-0.1%) to 96.158% when pulling 7522a4fe882f69f2563fce8c2bf56a01aadd67ce on acolomb:pass-partial-response-in-exception into f1128a73e43f565bacedd1ae99d077d7c9c831f3 on AdvancedClimateSystems:master.

acolomb commented 3 years ago

Applied the same treatment to the CRCError class, which is also useful in debugging.