use thiserror::Error;
pub type Result<T> = std::result::Result<T, RuvLLMError>;
#[derive(Error, Debug)]
pub enum RuvLLMError {
#[error("Storage error: {0}")]
Storage(String),
#[error("Session error: {0}")]
Session(String),
#[error("KV cache error: {0}")]
KvCache(String),
#[error("Paged attention error: {0}")]
PagedAttention(String),
#[error("Adapter error: {0}")]
Adapter(String),
#[error("Policy error: {0}")]
Policy(String),
#[error("Witness log error: {0}")]
WitnessLog(String),
#[error("SONA error: {0}")]
Sona(String),
#[error("Configuration error: {0}")]
Config(String),
#[error("Out of memory: {0}")]
OutOfMemory(String),
#[error("Invalid operation: {0}")]
InvalidOperation(String),
#[error("Not found: {0}")]
NotFound(String),
#[error("Serialization error: {0}")]
Serialization(String),
#[error("IO error: {0}")]
Io(#[from] std::io::Error),
#[error("Ruvector error: {0}")]
Ruvector(String),
#[error("Backend error: {0}")]
Backend(String),
#[error("Model error: {0}")]
Model(String),
#[error("Tokenization error: {0}")]
Tokenization(String),
#[error("Generation error: {0}")]
Generation(String),
#[error("Metal error: {0}")]
Metal(String),
#[error("Shader error: {0}")]
Shader(String),
#[error("GGUF error: {0}")]
Gguf(String),
#[error("Quantization error: {0}")]
Quantization(String),
#[error("Not implemented: {0}")]
NotImplemented(String),
#[error("Hybrid pipeline error: {0}")]
HybridPipeline(String),
#[error("Core ML error: {0}")]
CoreML(String),
}
impl From<ruvector_core::RuvectorError> for RuvLLMError {
fn from(err: ruvector_core::RuvectorError) -> Self {
RuvLLMError::Ruvector(err.to_string())
}
}
impl From<serde_json::Error> for RuvLLMError {
fn from(err: serde_json::Error) -> Self {
RuvLLMError::Serialization(err.to_string())
}
}