Skip to main content

waratah_text_index/
error.rs

1//! Errors of the partition-side text index engine.
2
3use std::path::PathBuf;
4
5/// Failure of a text-index operation.
6#[derive(Debug, thiserror::Error)]
7pub enum TextIndexError {
8    /// Tantivy reported a failure (I/O, schema, query parse, commit).
9    #[error("text index: {0}")]
10    Tantivy(#[from] tantivy::TantivyError),
11
12    /// The full-text query string could not be parsed.
13    #[error("text query is not valid: {0}")]
14    QueryParse(#[from] tantivy::query::QueryParserError),
15
16    /// A previous panic poisoned the writer mutex.
17    #[error("the text index writer lock is poisoned")]
18    WriterPoisoned,
19
20    /// A wipe is in progress: the put raced the fence and was rejected
21    /// before committing. The rejection maps to a transient status, but
22    /// the standard retry budget (milliseconds) is far shorter than any
23    /// wipe — in practice the insert fails loudly and the load is rerun
24    /// (documents are idempotent; no row lands on the rejected path).
25    #[error(
26        "the text index is wiping; the write failed — rerun the load once the rebuild finishes"
27    )]
28    WipeInProgress,
29
30    /// A filesystem operation failed.
31    #[error("text index io: {0}")]
32    Io(#[from] std::io::Error),
33
34    /// The configuration is not usable.
35    #[error("invalid text index config: {0}")]
36    Config(String),
37
38    /// The index directory was built with a different schema.
39    #[error(
40        "the text index on disk was built with a different schema (analyzer or seed length changed); rebuild the index"
41    )]
42    SchemaMismatch,
43
44    /// The search pattern produced no analyzable text.
45    #[error("the text candidate pattern is empty")]
46    EmptyPattern,
47
48    /// No index exists on this partition yet.
49    #[error(
50        "the text index has not been built on this partition; run `waratah text rebuild-index`"
51    )]
52    NotBuilt,
53
54    /// The candidate drain exceeded the per-request guard.
55    #[error(
56        "the text candidate set exceeded the per-request limit of {limit}; refine the query or raise the limit"
57    )]
58    CandidateLimitExceeded {
59        /// The configured per-request limit.
60        limit: u64,
61    },
62
63    /// The subject resolve exceeded the per-request distinct-row guard.
64    #[error(
65        "the text subject set exceeded the per-request limit of {limit}; refine the query or raise the limit"
66    )]
67    SubjectLimitExceeded {
68        /// The configured per-request limit.
69        limit: u64,
70    },
71
72    /// The sidecar metadata file is unreadable or malformed.
73    #[error("text index metadata at {path} is invalid: {detail}")]
74    Meta {
75        /// The metadata file path.
76        path: PathBuf,
77        /// What was wrong with it.
78        detail: String,
79    },
80}