reflex/cache/l2/
error.rs

1use crate::vectordb::VectorDbError;
2use thiserror::Error;
3
4#[derive(Debug, Error)]
5/// Errors returned by the L2 semantic cache.
6pub enum L2CacheError {
7    /// Embedding generation failed.
8    #[error("embedding generation failed: {reason}")]
9    EmbeddingFailed {
10        /// Error message.
11        reason: String,
12    },
13
14    /// Vector database error (search/upsert/etc).
15    #[error("vector database error: {0}")]
16    VectorDb(#[from] VectorDbError),
17
18    /// Full-precision rescoring failed.
19    #[error("rescoring failed: {reason}")]
20    RescoringFailed {
21        /// Error message.
22        reason: String,
23    },
24
25    /// Invalid configuration.
26    #[error("configuration error: {reason}")]
27    ConfigError {
28        /// Error message.
29        reason: String,
30    },
31
32    /// No candidates were returned (BQ stage empty or all candidates filtered).
33    #[error("no candidates found for query")]
34    NoCandidates,
35}
36
37/// Convenience result type for L2 operations.
38pub type L2CacheResult<T> = Result<T, L2CacheError>;