use thiserror::Error;
#[derive(Error, Debug)]
pub enum ClientError {
#[error("Path not found: {0}")]
PathNotFound(String),
#[error("Scalar path cannot be queried: {0}")]
ScalarPath(String),
#[error("Schema error: {0}")]
Schema(String),
#[error("Validation error: {0}")]
Validation(String),
#[error("Not found: {0}")]
NotFound(String),
#[error("Transaction error: {0}")]
Transaction(String),
#[error("Serialization failure: txn {our_txn} conflicts with {conflicting_txn} on key")]
SerializationFailure {
our_txn: u64,
conflicting_txn: u64,
conflicting_key: Vec<u8>,
},
#[error("MVCC visibility error: {0}")]
Visibility(String),
#[error("WAL error: {0}")]
Wal(String),
#[error("Storage error: {0}")]
Storage(String),
#[error("I/O error: {0}")]
Io(#[from] std::io::Error),
#[error("Serialization error: {0}")]
Serialization(String),
#[error("Parse error: {0}")]
Parse(String),
#[error("Constraint violation: {0}")]
Constraint(String),
#[error("Vector error: {0}")]
Vector(String),
#[error("Product quantization codebooks not trained")]
PqNotTrained,
#[error("Type mismatch: expected {expected}, got {actual}")]
TypeMismatch { expected: String, actual: String },
#[error("Token budget exceeded: {used} > {budget}")]
TokenBudgetExceeded { used: usize, budget: usize },
#[error("Connection pool exhausted")]
PoolExhausted,
#[error("Query error: {0}")]
Query(String),
#[error("Internal error: {0}")]
Internal(String),
}
impl From<bincode::Error> for ClientError {
fn from(e: bincode::Error) -> Self {
ClientError::Serialization(e.to_string())
}
}
pub type Result<T> = std::result::Result<T, ClientError>;