starfall/astronomy/close_binary_star/error/
mod.rs

1use crate::astronomy::star::error::Error as StarError;
2
3/// Close binary star-related errors.
4#[derive(Clone, Copy, Debug, Eq, Error, Hash, PartialEq)]
5pub enum Error {
6  /// Star Error.
7  #[error("an error occurred in the star ({0})")]
8  StarError(#[from] StarError),
9  /// Lower than MINIMUM_SEPARATION.
10  #[error("the stars are too close together to be stable")]
11  BinaryStarsTooCloseForComfort,
12  /// The habitable zone is contained within the forbidden zone.
13  #[error("the stars' habitable zone is contained within their forbidden zone")]
14  HabitableZoneContainedWithinForbiddenZone,
15  /// The habitable zone isn't sufficiently far from the host stars.
16  #[error("the stars' habitable zone is too close to the host stars")]
17  HabitableZoneContainedWithinDangerZone,
18  /// No habitable conditions found anywhere in StarSubsystem.
19  #[error("the stars do not have a habitable zone")]
20  NoHabitableZoneFound,
21  /// An unknown error occurred.
22  #[error("an unknown error occurred")]
23  UnknownError,
24}
25
26#[cfg(test)]
27pub mod test {
28
29  use super::*;
30  use crate::test::*;
31
32  #[named]
33  #[test]
34  pub fn test_errors() {
35    init();
36    trace_enter!();
37    let mut error = Error::BinaryStarsTooCloseForComfort;
38    print_var!(error);
39    error = Error::HabitableZoneContainedWithinForbiddenZone;
40    print_var!(error);
41    error = Error::HabitableZoneContainedWithinDangerZone;
42    print_var!(error);
43    error = Error::NoHabitableZoneFound;
44    print_var!(error);
45    error = Error::UnknownError;
46    print_var!(error);
47    error = Error::StarError(StarError::UnknownError);
48    print_var!(error);
49    error = StarError::UnknownError.into();
50    print_var!(error);
51    trace_exit!();
52  }
53}