Convert unknown error codes to a useful exception class.#112
Open
acolomb wants to merge 3 commits intoAdvancedClimateSystems:masterfrom
Open
Convert unknown error codes to a useful exception class.#112acolomb wants to merge 3 commits intoAdvancedClimateSystems:masterfrom
acolomb wants to merge 3 commits intoAdvancedClimateSystems:masterfrom
Conversation
Introduce an UndefinedModbusException class and use it when the lookup in error_code_to_exception_map fails. Previously that would just throw a KeyError with the contained value, so this change makes it more obvious what actually happened.
Contributor
Author
|
The docstrings for all these exception classes are somewhat inconsistent. If you like, I will include a commit making them PEP-257 compliant. |
The __repr__() special method is usually called in place of __str__(), but only if the latter is not defined. However the BaseException class already has a __str__() method, so we need to override that specifically. Note that this change doesn't touch the other cases below where the same problem exists. Initialize the error_code field explicitly using the KeyError argument instead of passing in the whole exception object.
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.
Introduce an UndefinedModbusException class and use it when the lookup
in error_code_to_exception_map fails. Previously that would just
throw a KeyError with the contained value, so this change makes it
more obvious what actually happened.