solverforge_service/
error.rs

1use thiserror::Error;
2
3#[derive(Error, Debug)]
4pub enum ServiceError {
5    #[error("Java not found: {0}")]
6    JavaNotFound(String),
7
8    #[error("Maven not found: {0}")]
9    MavenNotFound(String),
10
11    #[error("Build failed: {0}")]
12    BuildFailed(String),
13
14    #[error("Download failed: {0}")]
15    DownloadFailed(String),
16
17    #[error("Service failed to start: {0}")]
18    StartFailed(String),
19
20    #[error("Service unhealthy: {0}")]
21    Unhealthy(String),
22
23    #[error("IO error: {0}")]
24    Io(#[from] std::io::Error),
25
26    #[error("HTTP error: {0}")]
27    Http(String),
28
29    #[error("Submodule not found: {0}")]
30    SubmoduleNotFound(String),
31}
32
33pub type ServiceResult<T> = Result<T, ServiceError>;
34
35#[cfg(test)]
36mod tests {
37    use super::*;
38
39    #[test]
40    fn test_error_display() {
41        let err = ServiceError::JavaNotFound("java not in PATH".to_string());
42        assert!(err.to_string().contains("Java not found"));
43    }
44
45    #[test]
46    fn test_io_error_conversion() {
47        let io_err = std::io::Error::new(std::io::ErrorKind::NotFound, "file not found");
48        let err: ServiceError = io_err.into();
49        assert!(matches!(err, ServiceError::Io(_)));
50    }
51}