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