Module food_injection_error

Source
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 underlying AquaChannelError. 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 location and the specific AquariumDevice that was being controlled when the error occurred.

  • Error Collection: The FoodInjection process is designed to collect multiple errors into a Vec<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:

  1. Channel Communication Failures: These occur when sending a command to, or receiving a confirmation from, the RelayManager thread fails.

  2. Invalid State Errors: These occur if the logic attempts to set a device to an undefined state (i.e., something other than On or Off).

Enums§

FoodInjectionError
Contains error definition for FoodInjection