Skip to main content

spire_ai/
error.rs

1//! Error types for spire-ai.
2
3use thiserror::Error;
4
5/// Errors that can occur in spire-ai operations.
6#[derive(Debug, Error)]
7pub enum Error {
8    #[error("connection failed: {0}")]
9    Connection(String),
10
11    #[error("vector error: {0}")]
12    Vector(#[from] spiresql::vector::error::VectorError),
13
14    #[error("stream error: {0}")]
15    Stream(#[from] spiresql::stream::error::StreamError),
16
17    #[error("gRPC error: {0}")]
18    Grpc(#[from] tonic::Status),
19
20    #[error("gRPC transport error: {0}")]
21    Transport(#[from] tonic::transport::Error),
22
23    #[error("serialization error: {0}")]
24    Serialization(#[from] serde_json::Error),
25
26    #[error("embedding error: {0}")]
27    Embedding(String),
28
29    #[error("no embedder configured")]
30    NoEmbedder,
31
32    #[error("LLM error: {0}")]
33    Llm(String),
34
35    #[error("no LLM configured")]
36    NoLlm,
37
38    #[error("HTTP error: {0}")]
39    Http(#[from] reqwest::Error),
40
41    #[error("document not found: {0}")]
42    NotFound(String),
43
44    #[error("collection not initialized — call ensure() first")]
45    NotInitialized,
46
47    #[error("IO error: {0}")]
48    Io(#[from] std::io::Error),
49
50    #[error("tool error: {0}")]
51    Tool(String),
52
53    #[error("{0}")]
54    Other(String),
55}
56
57/// Result type alias for spire-ai.
58pub type Result<T> = std::result::Result<T, Error>;