Expand description
Contains error definition for food injection Defines the custom error type for the food injection process.
This module contains the FoodInjectionError enum, which consolidates all potential
failures that can occur when the FoodInjection controller executes a feed pattern.
By using a dedicated, descriptive error type, the system can provide clear diagnostics
when a feeding action fails.
§Design and Purpose
The FoodInjectionError enum is designed using the thiserror crate to provide
structured and informative error messages.
-
Source Chaining: For errors originating from channel communication (e.g.,
RelayManagerSend), the#[source]attribute preserves the underlyingAquaChannelError. This creates a full error chain, which is invaluable for debugging the root cause of a communication failure. -
Contextual Information: Each error variant includes important context, such as the code
locationand the specificAquariumDevicethat was being controlled when the error occurred. -
Error Collection: The
FoodInjectionprocess is designed to collect multiple errors into aVec<FoodInjectionError>rather than failing on the first one. This allows it to report a complete set of failures from a single injection attempt (e.g., if communication with multiple devices fails).
§Error Categories
The errors fall into two main categories:
-
Channel Communication Failures: These occur when sending a command to, or receiving a confirmation from, the
RelayManagerthread fails. -
Invalid State Errors: These occur if the logic attempts to set a device to an undefined state (i.e., something other than
OnorOff).
Enums§
- Food
Injection Error - Contains error definition for FoodInjection