Skip to main content

adk_rag/
error.rs

1//! Error types for the `adk-rag` crate.
2
3use thiserror::Error;
4
5/// Errors that can occur in RAG operations.
6#[derive(Debug, Error)]
7pub enum RagError {
8    /// An error occurred during embedding generation.
9    #[error("Embedding error ({provider}): {message}")]
10    EmbeddingError {
11        /// The embedding provider that produced the error.
12        provider: String,
13        /// A description of the failure.
14        message: String,
15    },
16
17    /// An error occurred in the vector store backend.
18    #[error("Vector store error ({backend}): {message}")]
19    VectorStoreError {
20        /// The vector store backend that produced the error.
21        backend: String,
22        /// A description of the failure.
23        message: String,
24    },
25
26    /// An error occurred during document chunking.
27    #[error("Chunking error: {0}")]
28    ChunkingError(String),
29
30    /// An error occurred during result reranking.
31    #[error("Reranker error ({reranker}): {message}")]
32    RerankerError {
33        /// The reranker that produced the error.
34        reranker: String,
35        /// A description of the failure.
36        message: String,
37    },
38
39    /// A configuration validation error.
40    #[error("Configuration error: {0}")]
41    ConfigError(String),
42
43    /// An error in the RAG pipeline orchestration.
44    #[error("Pipeline error: {0}")]
45    PipelineError(String),
46
47    /// An error propagated from `adk-core`.
48    #[error(transparent)]
49    AdkError(#[from] adk_core::AdkError),
50}
51
52/// A convenience result type for RAG operations.
53pub type Result<T> = std::result::Result<T, RagError>;