ricecoder_research/
error.rs1use std::path::PathBuf;
4use thiserror::Error;
5
6#[derive(Debug, Error)]
8pub enum ResearchError {
9 #[error("Project not found at {path}: {reason}")]
11 ProjectNotFound {
12 path: PathBuf,
14 reason: String,
16 },
17
18 #[error("Codebase scan failed: {reason}")]
20 ScanFailed {
21 reason: String,
23 },
24
25 #[error("Analysis failed: {reason}. Context: {context}")]
27 AnalysisFailed {
28 reason: String,
30 context: String,
32 },
33
34 #[error("Dependency parsing failed for {language}: {reason}")]
36 DependencyParsingFailed {
37 language: String,
39 path: Option<PathBuf>,
41 reason: String,
43 },
44
45 #[error("Semantic index error: {reason}. Operation: {operation}")]
47 IndexError {
48 reason: String,
50 operation: String,
52 },
53
54 #[error("Search failed for query '{query}': {reason}")]
56 SearchFailed {
57 query: String,
59 reason: String,
61 },
62
63 #[error("Cache error during {operation}: {reason}")]
65 CacheError {
66 operation: String,
68 reason: String,
70 },
71
72 #[error("IO error: {reason}")]
74 IoError {
75 reason: String,
77 },
78
79 #[error("Serialization error: {reason}. Format: {format}")]
81 SerializationError {
82 reason: String,
84 format: String,
86 },
87
88 #[error("Invalid configuration: {reason}. Expected: {expected}")]
90 InvalidConfiguration {
91 reason: String,
93 expected: String,
95 },
96}
97
98impl From<serde_json::Error> for ResearchError {
99 fn from(err: serde_json::Error) -> Self {
100 ResearchError::SerializationError {
101 reason: err.to_string(),
102 format: "JSON".to_string(),
103 }
104 }
105}
106
107impl From<toml::de::Error> for ResearchError {
108 fn from(err: toml::de::Error) -> Self {
109 ResearchError::SerializationError {
110 reason: err.to_string(),
111 format: "TOML".to_string(),
112 }
113 }
114}
115
116impl From<serde_yaml::Error> for ResearchError {
117 fn from(err: serde_yaml::Error) -> Self {
118 ResearchError::SerializationError {
119 reason: err.to_string(),
120 format: "YAML".to_string(),
121 }
122 }
123}