1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//! Error types for Irithyll.
//!
//! Core error types ([`ConfigError`], [`IrithyllError`]) are defined in
//! `irithyll-core` and re-exported here. This module extends `IrithyllError`
//! with std-only variants (`Serialization`, `ChannelClosed`).
// Re-export core error types.
pub use irithyll_core::error::ConfigError;
use thiserror::Error;
/// Top-level error type for the Irithyll crate.
///
/// Core variants (`InvalidConfig`, `InsufficientData`, `DimensionMismatch`,
/// `NotTrained`) mirror `irithyll_core::IrithyllError`. Std-only variants
/// (`Serialization`, `ChannelClosed`) are added here.
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum IrithyllError {
/// Configuration validation failed.
#[error("invalid configuration: {0}")]
InvalidConfig(#[from] ConfigError),
/// Not enough data to perform the requested operation.
#[error("insufficient data: {0}")]
InsufficientData(String),
/// Feature dimension mismatch between sample and model.
#[error("dimension mismatch: expected {expected}, got {got}")]
DimensionMismatch {
/// Expected number of features.
expected: usize,
/// Actual number of features received.
got: usize,
},
/// Model has not been trained yet.
#[error("model not trained")]
NotTrained,
/// Serialization or deserialization failed.
#[error("serialization error: {0}")]
Serialization(String),
/// Async channel closed unexpectedly.
#[error("channel closed")]
ChannelClosed,
}
/// Shorthand result type with [`IrithyllError`] as the error variant.
pub type Result<T> = std::result::Result<T, IrithyllError>;