use thiserror::Error;
#[derive(Debug, Error)]
pub enum JreError {
#[error("JRE not found at {path:?}")]
NotFound { path: std::path::PathBuf },
#[error("Invalid JRE structure in directory")]
InvalidStructure,
#[error("Download failed: {0}")]
Download(String),
#[error("Unsupported operating system for JRE installation")]
UnsupportedOS,
#[error("IO error: {0}")]
Io(#[from] std::io::Error),
#[error("Extraction failed: {0}")]
Extraction(String),
}
#[derive(Debug, Error)]
pub enum JavaRuntimeError {
#[error("Java runtime not found at {path:?}")]
NotFound { path: std::path::PathBuf },
#[error("Process exited with non-zero exit code: {code}")]
NonZeroExit { code: i32 },
#[error("Failed to capture process I/O - stdout/stderr not configured")]
IoCaptureFailure,
#[error("Process spawn error: {0}")]
Spawn(#[from] std::io::Error),
#[error("Process terminated by signal")]
SignalTerminated,
}
#[derive(Debug, Error)]
pub enum DistributionError {
#[error("Unsupported Java version {version} for distribution {distribution}")]
UnsupportedVersion { version: u8, distribution: &'static str },
#[error("API error for {distribution}: {error}")]
ApiError { distribution: &'static str, error: String },
#[error("JSON parse error for {distribution}: {error}")]
JsonParseError { distribution: &'static str, error: String },
#[error("No packages found for {distribution}")]
NoPackagesFound { distribution: &'static str },
#[error("System error: {0}")]
System(#[from] lighty_core::SystemError),
}
pub type JreResult<T> = Result<T, JreError>;
pub type JavaRuntimeResult<T> = Result<T, JavaRuntimeError>;
pub type DistributionResult<T> = Result<T, DistributionError>;