use thiserror::Error;
#[non_exhaustive]
#[derive(Debug, Error)]
pub enum KernelError {
#[error("LLM API error: {0}")]
LlmApi(String),
#[error("LLM rate limited: retry after {0}s")]
RateLimited(u64),
#[error("HTTP {status}: {message}")]
Http {
status: u16,
message: String,
},
#[error("Request timed out after {0}s")]
Timeout(u64),
#[error("Config error: {0}")]
Config(String),
#[error("Store error: {0}")]
Store(String),
#[error("Vault error: {0}")]
Vault(String),
#[error("IO error: {0}")]
Io(#[from] std::io::Error),
#[error("Search error: {0}")]
Search(String),
#[error("Embedding error: {0}")]
Embedding(String),
#[error("Discovery error: {0}")]
Discovery(String),
#[cfg(any(
feature = "provider",
feature = "client-async",
feature = "graph",
feature = "mcp",
feature = "install",
feature = "search",
feature = "vector-index",
feature = "qdrant",
feature = "elastic",
feature = "embedding-openai",
feature = "telemetry"
))]
#[error("Serialization error: {0}")]
Serialization(#[from] serde_json::Error),
}
impl KernelError {
pub fn embedding(e: impl std::fmt::Display) -> Self {
Self::Embedding(e.to_string())
}
pub fn discovery(e: impl std::fmt::Display) -> Self {
Self::Discovery(e.to_string())
}
}
pub type Result<T> = std::result::Result<T, KernelError>;