1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/// RAG engine errors.
#[derive(Debug, thiserror::Error)]
pub enum RagError {
/// Retrieval operation failed.
#[error("Retrieval error: {0}")]
Retrieve(String),
/// LLM generation failed.
#[error("Generation error: {0}")]
Generation(String),
/// Context window exceeded available token budget.
#[error("Context overflow: {used}/{max} tokens")]
ContextOverflow {
/// Number of tokens used.
used: usize,
/// Maximum allowed tokens.
max: usize,
},
/// No matching results found for the query.
#[error("No results found for query: {0}")]
NoResults(String),
/// Embedding generation failed.
#[error("Embedding error: {0}")]
Embedding(String),
/// Vector/metadata store operation failed.
#[error("Store error: {0}")]
Store(String),
/// Reranking operation failed.
#[error("Rerank error: {0}")]
Rerank(String),
/// Document chunking failed.
#[error("Chunking error: {0}")]
Chunking(String),
/// Query preprocessing (HYDE, expansion) failed.
#[error("Query preprocessing error: {0}")]
QueryPreprocessing(String),
/// Invalid or missing configuration.
#[error("Configuration error: {0}")]
Config(String),
/// LLM provider error.
#[error("Provider error: {0}")]
Provider(String),
/// Requested prompt template not found.
#[error("Template not found: {0}")]
TemplateNotFound(String),
/// Requested namespace not found in the store.
#[error("Namespace not found: {0}")]
NamespaceNotFound(String),
}
impl RagError {
/// Returns `true` if the error is transient and the operation can be retried.
pub fn is_retryable(&self) -> bool {
matches!(self, RagError::Retrieve(_) | RagError::Generation(_) | RagError::Store(_))
}
}