oxibonsai_eval/error.rs
1//! Error types for the evaluation harness.
2//!
3//! The error enum is marked `#[non_exhaustive]`: callers must include a
4//! wildcard arm when matching so that future variant additions are a
5//! non-breaking change.
6
7use thiserror::Error;
8
9/// Errors that can occur during model evaluation.
10#[derive(Debug, Error)]
11#[non_exhaustive]
12pub enum EvalError {
13 /// The provided dataset contains no examples.
14 #[error("dataset is empty")]
15 DatasetEmpty,
16
17 /// Input data has an unexpected or malformed format.
18 #[error("invalid format: {0}")]
19 InvalidFormat(String),
20
21 /// The model inference step failed.
22 #[error("inference failed: {0}")]
23 InferenceFailed(String),
24
25 /// An I/O error with a human-readable message (legacy string form).
26 #[error("I/O error: {0}")]
27 IoError(String),
28
29 /// Parsing of a value (e.g. JSON field, integer) failed.
30 #[error("parse error: {0}")]
31 ParseError(String),
32
33 /// A numerical invariant was violated (NaN, divide-by-zero, overflow).
34 #[error("numerical error: {0}")]
35 Numerical(String),
36
37 /// An I/O error bubbled up from the standard library.
38 ///
39 /// Preferred over [`EvalError::IoError`] for automatic `?`-propagation
40 /// of `std::io::Error` values.
41 #[error("I/O error: {0}")]
42 Io(#[from] std::io::Error),
43
44 /// The caller supplied data with the wrong metric shape or type.
45 #[error("metric mismatch: expected {expected}, got {got}")]
46 MetricMismatch {
47 /// Human-readable description of what was expected.
48 expected: &'static str,
49 /// Human-readable description of what was actually provided.
50 got: String,
51 },
52}