1use thiserror::Error;
5
6#[derive(Debug, Error)]
8pub enum JreError {
9 #[error("JRE not found at {path:?}")]
10 NotFound { path: std::path::PathBuf },
11
12 #[error("Invalid JRE structure in directory")]
13 InvalidStructure,
14
15 #[error("Download failed: {0}")]
16 Download(String),
17
18 #[error("Unsupported operating system for JRE installation")]
19 UnsupportedOS,
20
21 #[error("IO error: {0}")]
22 Io(#[from] std::io::Error),
23
24 #[error("Extraction failed: {0}")]
25 Extraction(String),
26}
27
28#[derive(Debug, Error)]
30pub enum JavaRuntimeError {
31 #[error("Java runtime not found at {path:?}")]
32 NotFound { path: std::path::PathBuf },
33
34 #[error("Process exited with non-zero exit code: {code}")]
35 NonZeroExit { code: i32 },
36
37 #[error("Failed to capture process I/O - stdout/stderr not configured")]
38 IoCaptureFailure,
39
40 #[error("Process spawn error: {0}")]
41 Spawn(#[from] std::io::Error),
42
43 #[error("Process terminated by signal")]
44 SignalTerminated,
45}
46
47#[derive(Debug, Error)]
49pub enum DistributionError {
50 #[error("Unsupported Java version {version} for distribution {distribution}")]
51 UnsupportedVersion { version: u8, distribution: &'static str },
52
53 #[error("API error for {distribution}: {error}")]
54 ApiError { distribution: &'static str, error: String },
55
56 #[error("JSON parse error for {distribution}: {error}")]
57 JsonParseError { distribution: &'static str, error: String },
58
59 #[error("No packages found for {distribution}")]
60 NoPackagesFound { distribution: &'static str },
61
62 #[error("System error: {0}")]
63 System(#[from] lighty_core::SystemError),
64}
65
66pub type JreResult<T> = Result<T, JreError>;
68
69pub type JavaRuntimeResult<T> = Result<T, JavaRuntimeError>;
71
72pub type DistributionResult<T> = Result<T, DistributionError>;