Coverage for src/ramses_rf/exceptions.py: 100%

25 statements  

« prev     ^ index     » next       coverage.py v7.11.3, created at 2026-01-05 21:44 +0100

1#!/usr/bin/env python3 

2"""RAMSES RF - exceptions above the packet/protocol/transport layer.""" 

3 

4from __future__ import annotations 

5 

6from ramses_tx.exceptions import ( 

7 PacketAddrSetInvalid as PacketAddrSetInvalid, 

8 PacketInvalid as PacketInvalid, 

9 PacketPayloadInvalid as PacketPayloadInvalid, 

10 ProtocolError as ProtocolError, 

11 RamsesException as RamsesException, 

12) 

13 

14 

15class _RamsesUpperError(RamsesException): 

16 """A failure in the upper layer (state/schema, gateway, bindings, schedule).""" 

17 

18 

19######################################################################################## 

20# Errors above the protocol/transport layer, incl. message processing, state & schema 

21 

22 

23class BindingError(_RamsesUpperError): 

24 """An error occurred when binding.""" 

25 

26 

27class BindingFsmError(BindingError): 

28 """The binding FSM was/became inconsistent (this shouldn't happen).""" 

29 

30 

31class BindingFlowFailed(BindingError): 

32 """The binding failed due to a timeout or retry limit being exceeded.""" 

33 

34 

35######################################################################################## 

36# Errors above the protocol/transport layer, incl. message processing, state & schema 

37 

38 

39class ScheduleError(_RamsesUpperError): 

40 """An error occurred when getting/setting a schedule.""" 

41 

42 

43class ScheduleFsmError(ScheduleError): 

44 """The schedule FSM was/became inconsistent (this shouldn't happen).""" 

45 

46 

47class ScheduleFlowError(ScheduleError): 

48 """The get/set schedule failed due to a timeout or retry limit being exceeded.""" 

49 

50 

51######################################################################################## 

52# Errors above the protocol/transport layer, incl. message processing, state & schema 

53 

54 

55class ExpiredCallbackError(_RamsesUpperError): 

56 """Raised when the callback has expired.""" 

57 

58 

59class SystemInconsistent(_RamsesUpperError): 

60 """Base class for exceptions in this module.""" 

61 

62 

63class SystemSchemaInconsistent(SystemInconsistent): 

64 """Raised when the system state (usu. schema) is inconsistent.""" 

65 

66 HINT = "try restarting the client library" 

67 

68 

69class DeviceNotFaked(SystemInconsistent): 

70 """Raised when the device does not have faking enabled.""" 

71 

72 HINT = "faking is configured in the known_list" 

73 

74 

75class ForeignGatewayError(SystemInconsistent): 

76 """Raised when a foreign gateway is detected. 

77 

78 These devices may not be gateways (set a class), or belong to a neighbour (exclude 

79 via block_list/known_list), or should be allowed (known_list).""" 

80 

81 HINT = "consider enforcing a known_list" 

82 

83 

84class DeviceNotRecognised(_RamsesUpperError): 

85 """Raised when a device is not recognized. 

86 

87 This typically happens when trying to interact with a device that doesn't exist 

88 or is not properly configured in the system.""" 

89 

90 HINT = "check the device ID and ensure the device is properly configured" 

91 

92 

93class CommandInvalid(_RamsesUpperError): 

94 """Raised when an invalid command is sent to a device. 

95 

96 This can happen if the command format is incorrect or if the command is not 

97 supported by the target device.""" 

98 

99 HINT = "verify the command format and ensure it's supported by the device" 

100 

101 

102class SendFailure(_RamsesUpperError): 

103 """Raised when a command fails to be sent to a device. 

104 

105 This typically indicates a communication issue with the device or gateway.""" 

106 

107 HINT = "check the device connection and try again" 

108 

109 

110class SendPriority(_RamsesUpperError): 

111 """Raised when the command queue is full. 

112 

113 This happens when too many commands are queued for sending and the queue 

114 has reached its maximum capacity.""" 

115 

116 HINT = "wait for pending commands to complete and try again"