use core::fmt;
#[cfg(feature = "std")]
use std::error::Error;
#[derive(Debug)]
pub struct InvalidArgumentError {
msg: &'static str,
}
impl fmt::Display for InvalidArgumentError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "InvalidArgumentError: {}", self.msg)
}
}
#[cfg(feature = "std")]
impl Error for InvalidArgumentError {}
#[derive(Debug)]
pub struct ModelScaleError {
msg: &'static str,
}
impl fmt::Display for ModelScaleError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "ModelScaleError: {}", self.msg)
}
}
#[cfg(feature = "std")]
impl Error for ModelScaleError {}
#[derive(Debug)]
pub enum RucrfError {
InvalidArgument(InvalidArgumentError),
ModelScale(ModelScaleError),
}
impl RucrfError {
pub(crate) const fn invalid_argument(msg: &'static str) -> Self {
Self::InvalidArgument(InvalidArgumentError { msg })
}
pub(crate) const fn model_scale(msg: &'static str) -> Self {
Self::ModelScale(ModelScaleError { msg })
}
}
impl fmt::Display for RucrfError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
Self::InvalidArgument(e) => e.fmt(f),
Self::ModelScale(e) => e.fmt(f),
}
}
}
#[cfg(feature = "std")]
impl Error for RucrfError {}
pub type Result<T, E = RucrfError> = core::result::Result<T, E>;