#[derive(Debug)]
#[non_exhaustive]
pub enum DemesError {
DemeError(String),
EpochError(String),
GraphError(String),
MigrationError(String),
PulseError(String),
YamlError(OpaqueYamlError),
#[cfg(feature = "json")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "json")))]
JsonError(OpaqueJSONError),
#[cfg(feature = "toml")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "toml")))]
TomlDeError(OpaqueTOMLError),
ValueError(String),
IOerror(OpaqueIOError),
}
#[derive(Debug)]
#[repr(transparent)]
pub struct OpaqueYamlError(pub(crate) serde_yaml::Error);
#[derive(Debug)]
#[repr(transparent)]
pub struct OpaqueIOError(pub(crate) std::io::Error);
#[cfg(feature = "json")]
#[derive(Debug)]
#[repr(transparent)]
pub struct OpaqueJSONError(pub(crate) serde_json::Error);
#[cfg(feature = "toml")]
#[derive(Debug)]
#[repr(transparent)]
pub struct OpaqueTOMLError(pub(crate) toml::de::Error);
impl std::fmt::Display for DemesError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
DemesError::DemeError(e) => write!(f, "deme error: {}", e),
DemesError::EpochError(e) => write!(f, "epoch error: {}", e),
DemesError::GraphError(e) => write!(f, "graph error: {}", e),
DemesError::MigrationError(e) => write!(f, "migration error: {}", e),
DemesError::PulseError(e) => write!(f, "pulse error: {}", e),
DemesError::YamlError(e) => write!(f, "yaml error: {}", e.0),
DemesError::ValueError(e) => write!(f, "value error: {}", e),
DemesError::IOerror(e) => write!(f, "io error: {}", e.0),
#[cfg(feature = "json")]
DemesError::JsonError(e) => write!(f, "JSON error: {e:?}"),
#[cfg(feature = "toml")]
DemesError::TomlDeError(e) => write!(f, "TOML deserialization error: {e:?}"),
}
}
}
impl std::error::Error for DemesError {}