Expand description
Contains error definitions for Balling Defines the custom error types for the Balling mineral dosing system.
This module contains the BallingError enum, which consolidates all potential
failures that can occur during the initialization and execution of the Balling
dosing controller. By using a dedicated, descriptive error type, the system can
provide clear diagnostics when the dosing logic fails.
§Design and Purpose
The BallingError enum is designed using the thiserror crate to provide
structured and informative error messages.
-
Source Chaining: For errors originating from the database layer (e.g.,
SetValueRetrievalError), the#[source]attribute preserves the underlyingSqlInterfaceError. This creates a full error chain, which is invaluable for debugging the root cause of a database failure. -
Rich Context: Each error variant is designed to include important context, such as the code
locationand the specificpump_idthat was involved when the error occurred.
§Error Categories
The errors fall into two main categories:
-
Configuration Validation Errors: These errors occur at startup when the
Balling::new()constructor validates the configuration. They prevent the application from starting with an invalid or illogical setup.ScheduleCheckIntervalZeroDosingIntervalShorterThanCheckIntervalInvalidDosingInterval
-
Runtime Errors: These errors can occur while the
Ballingthread is running.SetValueRetrievalError: A failure to fetch pump settings from the database.ReadDurationSinceLastDosingFailure: A failure to calculate the time since the last dosing event.CountdownCalculationInvalidPumpId: An internal logic error indicating an invalid pump ID was used.
Enums§
- Balling
Error - Contains error definitions for Balling