use std::error::Error as StdError;
use std::fmt;
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Error {
Config(String),
Layout(String),
Training(String),
Inference(String),
Io(String),
Serialization(String),
WeightsConfigMismatch(String),
}
impl fmt::Display for Error {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Config(message) => write!(formatter, "invalid configuration: {message}"),
Self::Layout(message) => write!(formatter, "layout error: {message}"),
Self::Training(message) => write!(formatter, "training error: {message}"),
Self::Inference(message) => write!(formatter, "inference error: {message}"),
Self::Io(message) => write!(formatter, "I/O error: {message}"),
Self::Serialization(message) => {
write!(formatter, "serialization error: {message}")
}
Self::WeightsConfigMismatch(message) => {
write!(formatter, "weights config mismatch: {message}")
}
}
}
}
impl StdError for Error {}