1use thiserror::Error;
2
3#[derive(Error, Debug)]
4pub enum AppInfoError {
5 #[error("Failed to read applications directory: {0}")]
6 DirectoryReadError(#[from] std::io::Error),
7
8 #[error("I/O error while {action} at {path}: {source}")]
9 Io {
10 action: &'static str,
11 path: String,
12 #[source]
13 source: std::io::Error,
14 },
15
16 #[error("Failed to parse application bundle: {path}")]
17 BundleParseError { path: String },
18
19 #[error("Failed to read Info.plist: {0}")]
20 PlistError(String),
21
22 #[error("Registry access error: {0}")]
23 RegistryError(String),
24
25 #[error("Application not found: {name}")]
26 AppNotFound { name: String },
27
28 #[error("Unsupported platform")]
29 UnsupportedPlatform,
30
31 #[error("Failed to get file icon: {0}")]
32 FileIconError(#[from] FileIconError),
33}
34
35#[derive(Error, Debug)]
36pub enum FileIconError {
37 #[error("Path does not exist")]
38 PathDoesNotExist,
39
40 #[error("Icon size cannot be zero")]
41 NullIconSize,
42
43 #[error("Icon size {requested} exceeds the maximum supported size of {maximum}")]
44 SizeTooLarge { requested: u16, maximum: u16 },
45
46 #[error("Invalid RGBA pixel buffer: expected {expected} bytes, got {actual}")]
47 InvalidPixelBuffer { expected: usize, actual: usize },
48
49 #[error("Failed to extract icon: {0}")]
50 Failed(String),
51
52 #[error("Platform not supported")]
53 PlatformNotSupported,
54}
55
56pub type Result<T> = std::result::Result<T, AppInfoError>;