1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/// Represents a propagation error caused by orbital elements divergence
#[derive(Debug, Clone)]
pub enum Error {
    OutOfRangeEccentricity {
        /// Eccentricity value (unitless)
        eccentricity: f64,

        /// Minutes since epoch
        t: f64,
    },

    OutOfRangePerturbedEccentricity {
        /// Eccentricity value (unitless)
        eccentricity: f64,

        /// Minutes since epoch
        t: f64,
    },

    NegativeSemiLatusRectum {
        /// Minutes since epoch
        t: f64,
    },
}

impl core::fmt::Display for Error {
    fn fmt(&self, formatter: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        match self {
            Error::OutOfRangeEccentricity { eccentricity, t } => formatter.write_fmt(
                core::format_args!(
                    "The propagated eccentricity ({}) is outside the range [0, 1[ {} minutes after epoch (before adding third-body perturbations)",
                    eccentricity,
                    t,
                )
            ),
            Error::OutOfRangePerturbedEccentricity { eccentricity, t } => formatter.write_fmt(
                core::format_args!(
                    "The propagated eccentricity ({}) is outside the range [0, 1[ {} minutes after epoch (after adding third-body perturbations)",
                    eccentricity,
                    t,
                )
            ),
            Error::NegativeSemiLatusRectum { t } => formatter.write_fmt(
                core::format_args!("The propagated semi-latus rectum is negative {} minutes after epoch", t)
            )
        }
    }
}

#[cfg(feature = "std")]
impl std::error::Error for Error {}