1use thiserror::Error;
2
3pub type Result<T> = std::result::Result<T, AppError>;
5
6#[derive(Error, Debug)]
8pub enum AppError {
9 #[error("Failed to retrieve system information: {message}")]
11 SystemInfo { message: String },
12
13 #[error("Platform operation failed: {message}")]
15 Platform { message: String },
16
17 #[error("I/O error: {0}")]
19 Io(#[from] std::io::Error),
20
21 #[error("Display error: {message}")]
23 Display { message: String },
24
25 #[cfg(windows)]
27 #[error("WMI query failed: {0}")]
28 Wmi(#[from] wmi::WMIError),
29}
30
31impl AppError {
32 pub fn system_info(message: impl Into<String>) -> Self {
33 Self::SystemInfo {
34 message: message.into(),
35 }
36 }
37
38 pub fn platform(message: impl Into<String>) -> Self {
39 Self::Platform {
40 message: message.into(),
41 }
42 }
43
44 pub fn display(message: impl Into<String>) -> Self {
45 Self::Display {
46 message: message.into(),
47 }
48 }
49}