# HG changeset patch # User Tuomo Valkonen # Date 1666597939 -10800 # Node ID 61b068c50e25a5e9d4f1292c3d4314bf6d7a7b4d # Parent 20db884b7028e2b53e861931d38c080f2278ec08 Added type for numerical errors diff -r 20db884b7028 -r 61b068c50e25 src/error.rs --- 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 = Result>; 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 {}