1use thiserror::Error;
2
3#[derive(Debug, Error)]
5pub enum SystemError {
6 #[error("Unsupported operating system")]
7 UnsupportedOS,
8
9 #[error("Unsupported architecture")]
10 UnsupportedArchitecture,
11
12 #[error("IO error: {0}")]
13 Io(#[from] std::io::Error),
14}
15
16#[derive(Debug, Error)]
18pub enum ExtractError {
19 #[error("Invalid ZIP entry at index {index}")]
20 ZipEntryNotFound { index: usize },
21
22 #[error("Path has no parent directory")]
23 InvalidPath,
24
25 #[error("Absolute paths not allowed: {path}")]
26 AbsolutePath { path: String },
27
28 #[error("Path traversal detected: {path} escapes base directory")]
29 PathTraversal { path: String },
30
31 #[error("File too large: {size} bytes (max: {max})")]
32 FileTooLarge { size: u64, max: u64 },
33
34 #[error("ZIP error: {0}")]
35 Zip(#[from] async_zip::error::ZipError),
36
37 #[error("TAR error: {0}")]
38 Tar(#[from] std::io::Error),
39}
40
41#[derive(Debug, Error)]
43pub enum DownloadError {
44 #[error("HTTP request failed: {0}")]
45 Http(#[from] reqwest::Error),
46
47 #[error("IO error: {0}")]
48 Io(#[from] std::io::Error),
49}
50
51pub type SystemResult<T> = Result<T, SystemError>;
53
54pub type ExtractResult<T> = Result<T, ExtractError>;
56
57#[derive(Debug, Error)]
59pub enum AppStateError {
60 #[error("Failed to create project directories")]
61 ProjectDirsCreation,
62
63 #[error("AppState not initialized")]
64 NotInitialized,
65}
66
67pub type DownloadResult<T> = Result<T, DownloadError>;
69
70pub type AppStateResult<T> = Result<T, AppStateError>;