system_theme/
error.rs

1//! Error module for system theme operations.
2use std::fmt::Display;
3
4/// Error type for system theme operations.
5#[derive(Debug)]
6pub enum Error {
7    /// Operation not supported by the platform.
8    Unsupported,
9    /// Data not available (or invalid).
10    Unavailable,
11    /// Internal platform error.
12    Platform(Box<dyn std::error::Error + Send + Sync>),
13}
14
15impl Display for Error {
16    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
17        match self {
18            Error::Unsupported => write!(f, "Unsupported operation"),
19            Error::Unavailable => write!(f, "Unavailable data"),
20            Error::Platform(err) => write!(f, "Platform error: {}", err),
21        }
22    }
23}
24
25impl std::error::Error for Error {}
26
27impl Error {
28    /// Create a new error from a platform error.
29    pub fn from_platform(err: impl std::error::Error + Send + Sync + 'static) -> Self {
30        Error::Platform(Box::new(err))
31    }
32}