use thiserror::Error;
pub use crate::date::YearMonthError;
#[derive(Debug, Error)]
pub enum Error {
#[error("year-month error: {0}")]
YearMonth(#[from] YearMonthError),
#[error("parquet I/O error: {0}")]
Parquet(String),
#[error("nport error: {0}")]
Nport(String),
#[error("xml error: {0}")]
Xml(String),
#[error("unknown index id: {0}")]
UnknownIndex(String),
#[error("no data for {index} at {year_month}")]
SnapshotNotFound { index: String, year_month: String },
#[error("http error: {0}")]
Http(#[from] reqwest::Error),
#[error("I/O error: {0}")]
Io(#[from] std::io::Error),
#[error("arrow error: {0}")]
Arrow(#[from] arrow::error::ArrowError),
#[error("parquet error: {0}")]
ParquetNative(#[from] parquet::errors::ParquetError),
#[error("json error: {0}")]
Json(#[from] serde_json::Error),
#[error("checksum mismatch for {file}: expected sha256:{expected} got sha256:{actual}")]
ChecksumMismatch {
file: String,
expected: String,
actual: String,
},
#[error("{0}")]
Other(String),
}
pub type Result<T, E = Error> = std::result::Result<T, E>;
pub type IndexkitError = Error;
impl From<anyhow::Error> for Error {
fn from(e: anyhow::Error) -> Self {
Error::Other(e.to_string())
}
}