Repository navigation
Throw friendly error when device is disconnected - #373
Conversation
| raise ValueError("The given speed value was out of range. Max speed: +/-" + str(max_speed)) from driver_error | ||
| raise ValueError("One or more arguments were out of range or invalid") from driver_error | ||
| elif driver_error.errno == errno.ENODEV: | ||
| raise Exception("The device is no longer connected") from driver_error |
There was a problem hiding this comment.
Why 'no longer'? Do we know it was ever connected?
There was a problem hiding this comment.
Currently, if it was never connected, the connected property is false and we throw an exception at a higher level. There's an if somewhere around here which handles that case.
There was a problem hiding this comment.
How about:
raise Exception("%s is no longer connected" % self) from driver_error
that way the exception has the __str__ of the device that was disconnected
There was a problem hiding this comment.
I haven't paid attention to how inheritance works in Python... Will that have the expected behavior? I know that __class__ is the type the method was defined in and not the runtime type of the enclosing object.
There was a problem hiding this comment.
The Device class has a __str__ that will be used to determine what to print whenver you have to print the object in a string
There was a problem hiding this comment.
The question I was asking was a technical one about the language. I'll figure it out and update as needed.
| attribute.seek(0) | ||
|
|
||
| try: | ||
| if None == attribute: |
There was a problem hiding this comment.
Do we follow PEP-8? If so we should do if attribute is None here.
There was a problem hiding this comment.
Yeah, this is existing code. I'll update it.
… into friendly-disconnect-errors
No description provided.