sklears_compose/
error.rs

1//! Error types for sklears-compose crate
2
3pub use sklears_core::error::{Result as SklResult, SklearsError};
4
5/// Result type alias for convenience
6pub type Result<T> = std::result::Result<T, SklearsComposeError>;
7
8/// Compose-specific error types
9#[derive(Debug, thiserror::Error)]
10pub enum SklearsComposeError {
11    /// Core sklears error
12    #[error(transparent)]
13    Core(#[from] SklearsError),
14
15    /// Invalid configuration
16    #[error("Invalid configuration: {0}")]
17    InvalidConfiguration(String),
18
19    /// Invalid data
20    #[error("Invalid data: {reason}")]
21    InvalidData { reason: String },
22
23    /// Invalid operation
24    #[error("Invalid operation: {0}")]
25    InvalidOperation(String),
26
27    /// Serialization error
28    #[error("Serialization error: {0}")]
29    Serialization(String),
30
31    /// I/O error
32    #[error("I/O error: {0}")]
33    Io(#[from] std::io::Error),
34
35    /// Other error
36    #[error("Error: {0}")]
37    Other(String),
38}
39
40impl From<String> for SklearsComposeError {
41    fn from(s: String) -> Self {
42        Self::Other(s)
43    }
44}
45
46impl From<&str> for SklearsComposeError {
47    fn from(s: &str) -> Self {
48        Self::Other(s.to_string())
49    }
50}