#[cfg(not(feature = "std"))]
use alloc::string::String;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum ZkmlError {
FeatureCountMismatch { expected: usize, got: usize },
InvalidModel(String),
ParseError(String),
ArithmeticOverflow,
QuantizationError(String),
}
impl core::fmt::Display for ZkmlError {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
ZkmlError::FeatureCountMismatch { expected, got } => {
write!(f, "feature count mismatch: expected {expected}, got {got}")
}
ZkmlError::InvalidModel(m) => write!(f, "invalid model: {m}"),
ZkmlError::ParseError(m) => write!(f, "parse error: {m}"),
ZkmlError::ArithmeticOverflow => write!(f, "arithmetic overflow"),
ZkmlError::QuantizationError(m) => write!(f, "quantization error: {m}"),
}
}
}
#[cfg(feature = "std")]
impl std::error::Error for ZkmlError {}