-
Notifications
You must be signed in to change notification settings - Fork 8
Change asserts to raised exceptions. #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Can you point me to a library which I can use as coding reference? |
There are actually a few already in this library. Ex: if some_check:
raise SomeException("Some useful info about what went wrong.") Note that asserts trigger when the condition is false, so you'll want to kind of "invert" the existing checks. Also, pick an appropriate exception type. Read through the available ones and pick one that applies: |
I think that
assert 0 <= channel < _CHANNELS * self._n , \
"'channel' out of range (0,%s)" % _CHANNELS * self._n -1
try:
high_byte = self._shift_reg[byte_start]
low_byte = self._shift_reg[byte_start+1]
except IndexError:
print("'channel' out of range(0,%s)" % _CHANNELS * self._n -1) What do you think? |
We've been doing |
Thanks for your insight. |
Yes please. |
According to Issue adafruit#10 of the main repo, exceptions shall be used instead of asserts. I'm game.
Fixed with #15 |
Replace asserts with appropriate raised exception with helpful message.
The text was updated successfully, but these errors were encountered: