1use std::fmt;
4
5#[derive(Debug, Clone)]
7pub enum DataSketchesError {
8 CreationError(String),
10 SerializationError(String),
12 DeserializationError(String),
14 InvalidParameter(String),
16 NullPointer,
18 Unknown(String),
20}
21
22impl fmt::Display for DataSketchesError {
23 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
24 match self {
25 DataSketchesError::CreationError(msg) => write!(f, "Sketch creation error: {}", msg),
26 DataSketchesError::SerializationError(msg) => write!(f, "Serialization error: {}", msg),
27 DataSketchesError::DeserializationError(msg) => {
28 write!(f, "Deserialization error: {}", msg)
29 }
30 DataSketchesError::InvalidParameter(msg) => write!(f, "Invalid parameter: {}", msg),
31 DataSketchesError::NullPointer => write!(f, "Null pointer encountered"),
32 DataSketchesError::Unknown(msg) => write!(f, "Unknown error: {}", msg),
33 }
34 }
35}
36
37impl std::error::Error for DataSketchesError {}
38
39pub type Result<T> = std::result::Result<T, DataSketchesError>;