Skip to content

Conversation

@acolomb
Copy link
Contributor

@acolomb acolomb commented Feb 3, 2021

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.

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.
@coveralls
Copy link

coveralls commented Feb 3, 2021

Coverage Status

Coverage decreased (-0.3%) to 95.969% when pulling c3212d6 on acolomb:handle-undefined-error-codes into f1128a7 on AdvancedClimateSystems:master.

@acolomb
Copy link
Contributor Author

acolomb commented Feb 3, 2021

The docstrings for all these exception classes are somewhat inconsistent. If you like, I will include a commit making them PEP-257 compliant.

acolomb added 2 commits March 10, 2021 12:32
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants