Pass a partially received response in the ValueError exception.#113
Open
acolomb wants to merge 2 commits intoAdvancedClimateSystems:masterfrom
Open
Pass a partially received response in the ValueError exception.#113acolomb wants to merge 2 commits intoAdvancedClimateSystems:masterfrom
acolomb wants to merge 2 commits intoAdvancedClimateSystems:masterfrom
Conversation
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.
When a serial CRC validation fails, the exception is constructed with a descriptive text as its only argument. To aid in debugging, pass in the original failing message instead. Make sure the string representation of the exception stays the same, by adding a __str__() method like in the library's other exceptions.
Contributor
Author
|
Applied the same treatment to the CRCError class, which is also useful in debugging. |
alexrudd2
pushed a commit
to alexrudd2/uModbus
that referenced
this pull request
Oct 9, 2025
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. Via AdvancedClimateSystems#113
alexrudd2
pushed a commit
to alexrudd2/uModbus
that referenced
this pull request
Oct 9, 2025
When a serial CRC validation fails, the exception is constructed with a descriptive text as its only argument. To aid in debugging, pass in the original failing message instead. Make sure the string representation of the exception stays the same, by adding a __str__() method like in the library's other exceptions. Via AdvancedClimateSystems#113
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
ValueErrorexception 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, aTimeoutErroror similar might be easier to understand?