1use std::path::PathBuf;
2
3#[derive(Debug, thiserror::Error)]
17pub enum ArgusError {
18 #[error("IO error: {0}")]
20 Io(#[from] std::io::Error),
21
22 #[error("configuration error: {0}")]
24 Config(String),
25
26 #[error("git error: {0}")]
28 Git(String),
29
30 #[error("parse error: {0}")]
32 Parse(String),
33
34 #[error("LLM error: {0}")]
36 Llm(String),
37
38 #[error("serialization error: {0}")]
40 Serialization(#[from] serde_json::Error),
41
42 #[error("TOML parse error: {0}")]
44 Toml(#[from] toml::de::Error),
45
46 #[error("file not found: {}", .0.display())]
48 FileNotFound(PathBuf),
49
50 #[error("embedding error: {0}")]
52 Embedding(String),
53
54 #[error("database error: {0}")]
56 Database(String),
57}
58
59#[cfg(test)]
60mod tests {
61 use super::*;
62
63 #[test]
64 fn io_error_converts() {
65 let io_err = std::io::Error::new(std::io::ErrorKind::NotFound, "gone");
66 let err: ArgusError = io_err.into();
67 assert!(err.to_string().contains("gone"));
68 }
69
70 #[test]
71 fn config_error_displays_message() {
72 let err = ArgusError::Config("bad value".into());
73 assert_eq!(err.to_string(), "configuration error: bad value");
74 }
75
76 #[test]
77 fn file_not_found_shows_path() {
78 let err = ArgusError::FileNotFound(PathBuf::from("/tmp/missing.rs"));
79 assert!(err.to_string().contains("/tmp/missing.rs"));
80 }
81}