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
« 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."""
4from __future__ import annotations
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)
15class _RamsesUpperError(RamsesException):
16 """A failure in the upper layer (state/schema, gateway, bindings, schedule)."""
19########################################################################################
20# Errors above the protocol/transport layer, incl. message processing, state & schema
23class BindingError(_RamsesUpperError):
24 """An error occurred when binding."""
27class BindingFsmError(BindingError):
28 """The binding FSM was/became inconsistent (this shouldn't happen)."""
31class BindingFlowFailed(BindingError):
32 """The binding failed due to a timeout or retry limit being exceeded."""
35########################################################################################
36# Errors above the protocol/transport layer, incl. message processing, state & schema
39class ScheduleError(_RamsesUpperError):
40 """An error occurred when getting/setting a schedule."""
43class ScheduleFsmError(ScheduleError):
44 """The schedule FSM was/became inconsistent (this shouldn't happen)."""
47class ScheduleFlowError(ScheduleError):
48 """The get/set schedule failed due to a timeout or retry limit being exceeded."""
51########################################################################################
52# Errors above the protocol/transport layer, incl. message processing, state & schema
55class ExpiredCallbackError(_RamsesUpperError):
56 """Raised when the callback has expired."""
59class SystemInconsistent(_RamsesUpperError):
60 """Base class for exceptions in this module."""
63class SystemSchemaInconsistent(SystemInconsistent):
64 """Raised when the system state (usu. schema) is inconsistent."""
66 HINT = "try restarting the client library"
69class DeviceNotFaked(SystemInconsistent):
70 """Raised when the device does not have faking enabled."""
72 HINT = "faking is configured in the known_list"
75class ForeignGatewayError(SystemInconsistent):
76 """Raised when a foreign gateway is detected.
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)."""
81 HINT = "consider enforcing a known_list"
84class DeviceNotRecognised(_RamsesUpperError):
85 """Raised when a device is not recognized.
87 This typically happens when trying to interact with a device that doesn't exist
88 or is not properly configured in the system."""
90 HINT = "check the device ID and ensure the device is properly configured"
93class CommandInvalid(_RamsesUpperError):
94 """Raised when an invalid command is sent to a device.
96 This can happen if the command format is incorrect or if the command is not
97 supported by the target device."""
99 HINT = "verify the command format and ensure it's supported by the device"
102class SendFailure(_RamsesUpperError):
103 """Raised when a command fails to be sent to a device.
105 This typically indicates a communication issue with the device or gateway."""
107 HINT = "check the device connection and try again"
110class SendPriority(_RamsesUpperError):
111 """Raised when the command queue is full.
113 This happens when too many commands are queued for sending and the queue
114 has reached its maximum capacity."""
116 HINT = "wait for pending commands to complete and try again"