Skip to main content

zeph_index/
error.rs

1// SPDX-FileCopyrightText: 2026 Andrei G <bug-ops>
2// SPDX-License-Identifier: MIT OR Apache-2.0
3
4//! Error types for zeph-index.
5
6use std::num::TryFromIntError;
7
8/// Errors that can occur during code indexing operations.
9#[derive(Debug, thiserror::Error)]
10pub enum IndexError {
11    /// IO error reading source files.
12    #[error("IO error: {0}")]
13    Io(#[from] std::io::Error),
14
15    /// `SQLite` database error.
16    #[error("database error: {0}")]
17    Sqlite(#[from] zeph_db::SqlxError),
18
19    /// Vector store error.
20    #[error("vector store error: {0}")]
21    VectorStore(#[from] zeph_memory::VectorStoreError),
22
23    /// LLM provider error (embedding).
24    #[error("LLM error: {0}")]
25    Llm(#[from] zeph_llm::LlmError),
26
27    /// JSON serialization/deserialization error.
28    #[error("JSON error: {0}")]
29    Json(#[from] serde_json::Error),
30
31    /// Tree-sitter parsing error.
32    #[error("parse failed: {0}")]
33    Parse(String),
34
35    /// Unsupported or unrecognized language.
36    #[error("unsupported language")]
37    UnsupportedLanguage,
38
39    /// File watcher error.
40    #[error("watcher error: {0}")]
41    Watcher(#[from] notify::Error),
42
43    /// Integer conversion error.
44    #[error("integer conversion failed: {0}")]
45    IntConversion(#[from] TryFromIntError),
46
47    /// Generic catch-all error.
48    #[error("{0}")]
49    Other(String),
50}
51
52/// Result type alias using `IndexError`.
53pub type Result<T> = std::result::Result<T, IndexError>;