diff --git a/src/error.rs b/src/error.rs index 69e6d188..866f0ce1 100644 --- a/src/error.rs +++ b/src/error.rs @@ -7,7 +7,7 @@ pub enum DemesError { #[error("{0:?}")] EpochError(String), #[error("{0:?}")] - TopLevelError(String), + GraphError(String), #[error("generation time must be > 0.0, got: {0:?}")] GenerationTimeError(f64), #[error("{0:?}")] diff --git a/src/lib.rs b/src/lib.rs index b1a11a61..d58a2b0f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -10,7 +10,7 @@ //! - https://doi.org/10.1371/journal.pgen.1000695 //! time_units: years //! generation_time: 25 -//! +//! //! demes: //! - name: ancestral //! description: Equilibrium/root population @@ -41,7 +41,7 @@ //! ancestors: [OOA] //! epochs: //! - {start_size: 510, end_size: 54090} -//! +//! //! migrations: //! - {demes: [YRI, OOA], rate: 25e-5} //! - {demes: [YRI, CEU], rate: 3e-5} @@ -61,7 +61,7 @@ //! assert_eq!(graph, roundtripped_graph); //! } //! -//! +//! //!for deme in graph.demes() { //! println!("{} {} {} {} {}", //! deme.name(), diff --git a/src/specification.rs b/src/specification.rs index cdeecd0f..0bfbb1a7 100644 --- a/src/specification.rs +++ b/src/specification.rs @@ -95,7 +95,7 @@ impl TryFrom for Time { if &string == "Infinity" { Ok(Self(f64::INFINITY)) } else { - Err(DemesError::TopLevelError(string)) + Err(DemesError::GraphError(string)) } } // Fall back to valid YAML representations @@ -2049,7 +2049,7 @@ impl Graph { } if !matches!(&self.time_units, TimeUnits::GENERATIONS) && self.generation_time.is_none() { - return Err(DemesError::TopLevelError( + return Err(DemesError::GraphError( "missing generation_time".to_string(), )); } @@ -2063,7 +2063,7 @@ impl Graph { match self.generation_time { Some(value) => { if !value.0.eq(&1.0) { - return Err(DemesError::TopLevelError( + return Err(DemesError::GraphError( "time units are generations but generation_time != 1.0".to_string(), )); } diff --git a/tests/test_bad_yaml_inputs.rs b/tests/test_bad_yaml_inputs.rs index 77300ff6..85ec1816 100644 --- a/tests/test_bad_yaml_inputs.rs +++ b/tests/test_bad_yaml_inputs.rs @@ -824,7 +824,7 @@ demes: "; match demes::loads(yaml) { Ok(_) => panic!("expected Err!"), - Err(e) => assert!(matches!(e, demes::DemesError::TopLevelError(_))), + Err(e) => assert!(matches!(e, demes::DemesError::GraphError(_))), } }