use derive_more::{Display, From};
pub type Result<T> = core::result::Result<T, Error>;
#[derive(Debug, Display, From)]
#[display("{self:?}")]
pub enum Error {
#[from(String, &String, &str)]
Custom(String),
RuleFileNotFound(String),
RuleParseError(String),
InvalidRuleDefinition(String),
ConditionEvaluationFailed(String),
MissingCondition(String),
#[cfg(feature = "onnx")]
OnnxModelLoadFailed(String),
#[cfg(feature = "onnx")]
OnnxInferenceFailed(String),
#[from]
Io(std::io::Error),
#[from]
TomlParse(toml::de::Error),
#[from]
Hel(hel::HelError),
#[cfg(feature = "onnx")]
#[from]
TractOnnx(tract_onnx::prelude::TractError),
}
impl Error {
pub fn custom_from_err(err: impl std::error::Error) -> Self {
Self::Custom(err.to_string())
}
pub fn custom(val: impl Into<String>) -> Self {
Self::Custom(val.into())
}
}
impl std::error::Error for Error {}