|
1 | 1 | from __future__ import unicode_literals |
2 | 2 |
|
3 | 3 |
|
4 | | -class IncompatibleFrame(Exception): |
| 4 | +############################################################################### |
| 5 | +# general |
| 6 | +############################################################################### |
| 7 | + |
| 8 | +class DALIError(Exception): |
| 9 | + """Base exception for DALI related errors.""" |
| 10 | + |
| 11 | + |
| 12 | +############################################################################### |
| 13 | +# address |
| 14 | +############################################################################### |
| 15 | + |
| 16 | +class AddressError(DALIError): |
| 17 | + """Base Exception for address related errors.""" |
| 18 | + |
| 19 | + |
| 20 | +class IncompatibleFrame(AddressError): |
5 | 21 | """Cannot set destination address in supplied frame""" |
6 | 22 |
|
7 | 23 |
|
8 | | -class DuplicateDevice(Exception): |
9 | | - """Attempt to add more than one device with the same short address |
10 | | - to a bus. |
11 | | - """ |
| 24 | +############################################################################### |
| 25 | +# command |
| 26 | +############################################################################### |
| 27 | + |
| 28 | +class CommandError(DALIError): |
| 29 | + """Base Exception for command related errors.""" |
| 30 | + |
| 31 | + |
| 32 | +class MissingResponse(CommandError): |
| 33 | + """Response was absent where a response was expected.""" |
| 34 | + |
| 35 | + |
| 36 | +class ResponseError(CommandError): |
| 37 | + """Response had unexpected framing error.""" |
12 | 38 |
|
13 | 39 |
|
14 | | -class BadDevice(Exception): |
| 40 | +############################################################################### |
| 41 | +# bus |
| 42 | +############################################################################### |
| 43 | + |
| 44 | +class BusError(DALIError): |
| 45 | + """Base Exception for bus related errors.""" |
| 46 | + |
| 47 | + |
| 48 | +class BadDevice(BusError): |
15 | 49 | """Device with invalid attributes.""" |
16 | 50 |
|
17 | 51 |
|
18 | | -class DeviceAlreadyBound(Exception): |
| 52 | +class DeviceAlreadyBound(BusError): |
19 | 53 | """Attempt to add a device to a bus that is already bound to a |
20 | 54 | different bus. |
21 | 55 | """ |
22 | 56 |
|
23 | 57 |
|
24 | | -class NotConnected(Exception): |
25 | | - """A connection to the DALI bus is required to complete this |
26 | | - operation, but the bus is not connected. |
| 58 | +class DuplicateDevice(BusError): |
| 59 | + """Attempt to add more than one device with the same short address |
| 60 | + to a bus. |
27 | 61 | """ |
28 | 62 |
|
29 | 63 |
|
30 | | -class NoFreeAddress(Exception): |
| 64 | +class NoFreeAddress(BusError): |
31 | 65 | """An unused short address was required but none was available.""" |
32 | 66 |
|
33 | 67 |
|
34 | | -class ProgramShortAddressFailure(Exception): |
| 68 | +class NotConnected(BusError): |
| 69 | + """A connection to the DALI bus is required to complete this |
| 70 | + operation, but the bus is not connected. |
| 71 | + """ |
| 72 | + |
| 73 | + |
| 74 | +class ProgramShortAddressFailure(BusError): |
35 | 75 | """A device did not accept programming of its short address.""" |
36 | 76 |
|
37 | 77 | def __init__(self, address): |
38 | 78 | self.address = address |
39 | 79 |
|
40 | 80 |
|
41 | | -class MissingResponse(Exception): |
42 | | - """Response was absent where a response was expected.""" |
43 | | - |
| 81 | +############################################################################### |
| 82 | +# driver |
| 83 | +############################################################################### |
44 | 84 |
|
45 | | -class ResponseError(Exception): |
46 | | - """Response had unexpected framing error.""" |
| 85 | +class DriverError(DALIError): |
| 86 | + """Base Exception for driver related errors.""" |
47 | 87 |
|
48 | 88 |
|
49 | | -class CommunicationError(Exception): |
50 | | - """Exception raised in case of communication error with daliserver. |
| 89 | +class CommunicationError(DriverError): |
| 90 | + """Exception raised in case of communication error with backend. |
51 | 91 | """ |
0 commit comments