use thiserror::Error;
pub type Result<T> = std::result::Result<T, AppError>;
#[derive(Error, Debug)]
pub enum AppError {
#[error("Failed to retrieve system information: {message}")]
SystemInfo { message: String },
#[error("Platform operation failed: {message}")]
Platform { message: String },
#[error("I/O error: {0}")]
Io(#[from] std::io::Error),
#[error("Configuration error: {message}")]
Config { message: String },
#[error("Display error: {message}")]
Display { message: String },
#[cfg(windows)]
#[error("WMI query failed: {0}")]
Wmi(#[from] wmi::WMIError),
}
impl AppError {
pub fn system_info(message: impl Into<String>) -> Self {
Self::SystemInfo {
message: message.into(),
}
}
pub fn platform(message: impl Into<String>) -> Self {
Self::Platform {
message: message.into(),
}
}
pub fn config(message: impl Into<String>) -> Self {
Self::Config {
message: message.into(),
}
}
pub fn display(message: impl Into<String>) -> Self {
Self::Display {
message: message.into(),
}
}
}