-
Notifications
You must be signed in to change notification settings - Fork 5
Description
It is expected of peripheral devices that they sometimes behave unpredictably. For example, hardware issues (loose connectors, timing issues) can cause problems with communication. This can lead to a variety of exceptions.
Currently, any such exception stops the program, even though other peripherals might still be working as expected. This can be troublesome especially for kits that are controlling actuators such as lights or climate control, as the control process also stops.
There are multiple ways to implement handling of such exceptions. For example:
- the program could indiscriminately catch any
Exception(which does not include e.g.KeyboardInterruptandSystemExit); or - a
PeripheralDeviceExceptioncould be created, with peripheral device code being required to catch exceptions to rethrow asPeripheralDeviceException.
The first alternative works in most cases, but has the con of potentially catching too many exceptions (but which would we not want to catch?). The second alternative is likely to sometimes still fail for some unforeseen exceptions.
Once an exception has been caught for a peripheral device, for now we might simply ignore that device. In the future, an attempt at recovering the device might be implemented.