anda_db_tfs/
error.rs

1use thiserror::Error;
2
3pub type BoxError = Box<dyn std::error::Error + Send + Sync>;
4
5/// Errors that can occur when working with BM25 index.
6#[derive(Error, Debug)]
7pub enum BM25Error {
8    /// Index-related errors.
9    #[error("BM25 index {name:?}, error: {source:?}")]
10    Generic { name: String, source: BoxError },
11
12    /// CBOR serialization/deserialization errors
13    #[error("BM25 index {name:?}, CBOR serialization error: {source:?}")]
14    Serialization { name: String, source: BoxError },
15
16    /// Error when a token is not found.
17    #[error("BM25 index {name:?}, token not found: {token:?}")]
18    NotFound { name: String, token: String },
19
20    /// Error when trying to add a segment with an ID that already exists
21    #[error("BM25 index {name:?}, segment {id} already exists")]
22    AlreadyExists { name: String, id: u64 },
23
24    /// Error when tokenization produces no tokens for a segment
25    #[error("BM25 index {name:?}, segment {id} tokenization failed: {text:?}")]
26    TokenizeFailed { name: String, id: u64, text: String },
27}