num_notation/
err.rs

1use std::num::ParseFloatError;
2
3use thiserror::Error;
4
5use fraction::error::ParseError as ParsingFractionError;
6use standardform::ParsingStandardFormError ;
7
8/// Error type for parsing number-related errors.
9/// This error type encapsulates specific parsing errors for fractions, floating-point numbers,
10/// and numbers in standard form.
11#[derive(Error,Debug,Clone)]
12#[error("Failed to parse the number:\nfraction error: {fraction},\ndouble error: {double},\nstandard form error: {sf}",)]
13pub struct ParsingNumberError {
14    fraction : ParsingFractionError,
15    double : ParseFloatError,
16    sf : ParsingStandardFormError 
17}
18
19impl ParsingNumberError {
20    pub(crate) fn new(fraction : ParsingFractionError, double : ParseFloatError,sf : ParsingStandardFormError) -> Self {
21        Self { fraction , double , sf }
22    }
23
24    /// Retrieves a reference to the parsing error related to fractions.
25    pub fn fraction(&self) -> &ParsingFractionError {
26        &self.fraction
27    }
28
29    /// Retrieves a reference to the parsing error related to floating-point numbers.
30    pub fn double(&self) -> &ParseFloatError {
31        &self.double
32    }
33
34    /// Retrieves a reference to the parsing error related to numbers in standard form.
35    pub fn standardform(&self) -> &ParsingStandardFormError {
36        &self.sf
37    }
38}