Skip to main content

datasynth_eval/
error.rs

1//! Error types for the evaluation framework.
2
3use thiserror::Error;
4
5/// Errors that can occur during evaluation.
6#[derive(Debug, Error)]
7pub enum EvalError {
8    /// Insufficient data for statistical analysis.
9    #[error("Insufficient data: need at least {required} samples, got {actual}")]
10    InsufficientData { required: usize, actual: usize },
11
12    /// Invalid parameter value.
13    #[error("Invalid parameter: {0}")]
14    InvalidParameter(String),
15
16    /// Statistical computation error.
17    #[error("Statistical computation error: {0}")]
18    StatisticalError(String),
19
20    /// IO error during report generation.
21    #[error("IO error: {0}")]
22    IoError(#[from] std::io::Error),
23
24    /// Serialization error.
25    #[error("Serialization error: {0}")]
26    SerializationError(#[from] serde_json::Error),
27
28    /// Missing required data.
29    #[error("Missing required data: {0}")]
30    MissingData(String),
31
32    /// Evaluation threshold exceeded.
33    #[error("Threshold exceeded for {metric}: {value} (threshold: {threshold})")]
34    ThresholdExceeded {
35        metric: String,
36        value: f64,
37        threshold: f64,
38    },
39}
40
41/// Result type for evaluation operations.
42pub type EvalResult<T> = Result<T, EvalError>;