Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3818c56

Browse files
committed
Introduce topic related base exceptions and derive concrete exceptions from it
1 parent 636dbde commit 3818c56

File tree

1 file changed

+59
-19
lines changed

1 file changed

+59
-19
lines changed

dali/exceptions.py

Lines changed: 59 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,91 @@
11
from __future__ import unicode_literals
22

33

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):
521
"""Cannot set destination address in supplied frame"""
622

723

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."""
1238

1339

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):
1549
"""Device with invalid attributes."""
1650

1751

18-
class DeviceAlreadyBound(Exception):
52+
class DeviceAlreadyBound(BusError):
1953
"""Attempt to add a device to a bus that is already bound to a
2054
different bus.
2155
"""
2256

2357

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.
2761
"""
2862

2963

30-
class NoFreeAddress(Exception):
64+
class NoFreeAddress(BusError):
3165
"""An unused short address was required but none was available."""
3266

3367

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):
3575
"""A device did not accept programming of its short address."""
3676

3777
def __init__(self, address):
3878
self.address = address
3979

4080

41-
class MissingResponse(Exception):
42-
"""Response was absent where a response was expected."""
43-
81+
###############################################################################
82+
# driver
83+
###############################################################################
4484

45-
class ResponseError(Exception):
46-
"""Response had unexpected framing error."""
85+
class DriverError(DALIError):
86+
"""Base Exception for driver related errors."""
4787

4888

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.
5191
"""

0 commit comments

Comments
 (0)