use std::path::PathBuf;
use thiserror::Error;
#[derive(Error, Debug)]
pub enum JplephemError {
#[error("File I/O error on {path:?}: {source}")]
FileError {
path: PathBuf,
source: std::io::Error,
},
#[error("Date JD {jd} is outside ephemeris range ({start_jd}..{end_jd})")]
OutOfRangeError { jd: f64, start_jd: f64, end_jd: f64 },
#[error("Invalid file format: {0}")]
InvalidFormat(String),
#[error("Memory mapping error: {0}")]
MemoryMapError(String),
#[error("Body not found: center={center}, target={target}")]
BodyNotFound { center: i32, target: i32 },
#[error("Unsupported SPK data type: {0}")]
UnsupportedDataType(i32),
#[error("{0}")]
Other(String),
}
pub type Result<T> = std::result::Result<T, JplephemError>;
pub fn io_err(path: impl Into<PathBuf>, err: std::io::Error) -> JplephemError {
JplephemError::FileError {
path: path.into(),
source: err,
}
}