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    /// Main thread required error.
12    MainThreadRequired,
13    /// Internal platform error.
14    Platform(Box<dyn std::error::Error + Send + Sync>),
15}
16
17impl Display for Error {
18    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
19        match self {
20            Error::Unsupported => write!(f, "Unsupported operation"),
21            Error::Unavailable => write!(f, "Unavailable data"),
22            Error::MainThreadRequired => write!(f, "Main thread required"),
23            Error::Platform(err) => write!(f, "Platform error: {}", err),
24        }
25    }
26}
27
28impl std::error::Error for Error {}
29
30impl Error {
31    /// Create a new error from a platform error.
32    pub fn from_platform(err: impl std::error::Error + Send + Sync + 'static) -> Self {
33        Error::Platform(Box::new(err))
34    }
35}