use std::error::Error;
use std::fmt::{self, Display, Formatter};
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum ModelError {
NotTrained,
InvalidClusterLabel(usize),
Inference(String),
}
impl Display for ModelError {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
match self {
Self::NotTrained => write!(f, "model has not been trained"),
Self::InvalidClusterLabel(l) => write!(f, "invalid cluster label {l}"),
Self::Inference(msg) => write!(f, "inference error: {msg}"),
}
}
}
impl Error for ModelError {}
pub type ModelResult<T> = Result<T, ModelError>;