use std::fmt;
#[derive(Debug, Clone)]
pub enum DataSketchesError {
CreationError(String),
SerializationError(String),
DeserializationError(String),
InvalidParameter(String),
NullPointer,
Unknown(String),
}
impl fmt::Display for DataSketchesError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
DataSketchesError::CreationError(msg) => write!(f, "Sketch creation error: {}", msg),
DataSketchesError::SerializationError(msg) => write!(f, "Serialization error: {}", msg),
DataSketchesError::DeserializationError(msg) => {
write!(f, "Deserialization error: {}", msg)
}
DataSketchesError::InvalidParameter(msg) => write!(f, "Invalid parameter: {}", msg),
DataSketchesError::NullPointer => write!(f, "Null pointer encountered"),
DataSketchesError::Unknown(msg) => write!(f, "Unknown error: {}", msg),
}
}
}
impl std::error::Error for DataSketchesError {}
pub type Result<T> = std::result::Result<T, DataSketchesError>;