Mon, 24 Oct 2022 10:52:19 +0300
Added type for numerical errors
src/error.rs | file | annotate | diff | comparison | revisions |
--- a/src/error.rs Mon Oct 24 09:41:43 2022 +0300 +++ b/src/error.rs Mon Oct 24 10:52:19 2022 +0300 @@ -4,5 +4,20 @@ pub type DynResult<T> = Result<T, Box<dyn Error>>; pub type DynError = DynResult<()>; +#[derive(Clone, Debug)] +/// Type for numerical errors. +pub struct NumericalError( + /// Provides additional information about the error + pub &'static str +); +impl std::fmt::Display for NumericalError { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self.0 { + "" => write!(f, "Numerical error"), + s => write!(f, "{s}"), + } + } +} +impl std::error::Error for NumericalError {}