starfall/astronomy/close_binary_star/error/
mod.rs1use crate::astronomy::star::error::Error as StarError;
2
3#[derive(Clone, Copy, Debug, Eq, Error, Hash, PartialEq)]
5pub enum Error {
6 #[error("an error occurred in the star ({0})")]
8 StarError(#[from] StarError),
9 #[error("the stars are too close together to be stable")]
11 BinaryStarsTooCloseForComfort,
12 #[error("the stars' habitable zone is contained within their forbidden zone")]
14 HabitableZoneContainedWithinForbiddenZone,
15 #[error("the stars' habitable zone is too close to the host stars")]
17 HabitableZoneContainedWithinDangerZone,
18 #[error("the stars do not have a habitable zone")]
20 NoHabitableZoneFound,
21 #[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}