use thiserror::Error;
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum Error {
#[error("Missing required OMM field {0}")]
MissingField(&'static str),
#[error("Invalid OMM field {field}: {message}")]
InvalidField {
field: &'static str,
message: String,
},
#[error(transparent)]
InvalidEpoch(#[from] crate::time::InstantError),
#[error("Unsupported MEAN_ELEMENT_THEORY: {0}")]
UnsupportedMeanElementTheory(String),
#[error("Unsupported TIME_SYSTEM for SGP4: {0}")]
UnsupportedTimeSystem(String),
#[error(
"Unsupported EPHEMERIS_TYPE {0}: satkit implements classic SGP4 only (type 4 is SGP4-XP)"
)]
UnsupportedEphemerisType(u8),
#[error("Expected a JSON OMM object or an array of OMM objects, found {0}")]
UnexpectedJsonShape(&'static str),
#[error("Input is neither JSON (starts with '[' or '{{') nor XML (starts with '<'); KVN is not supported")]
UnrecognizedFormat,
#[error(transparent)]
Json(#[from] serde_json::Error),
#[error(transparent)]
Io(#[from] std::io::Error),
#[cfg(feature = "download")]
#[error(transparent)]
Http(#[from] ureq::Error),
#[cfg(feature = "download")]
#[error("{0}")]
HttpThrottled(String),
#[error("Input appears to be XML but the `omm-xml` feature is not enabled")]
XmlFeatureDisabled,
#[cfg(feature = "omm-xml")]
#[error(transparent)]
Xml(#[from] quick_xml::DeError),
}
pub type Result<T> = std::result::Result<T, Error>;