#[derive(Debug, PartialEq)]
pub enum N3gbError {
InvalidIdentifierLength,
InvalidChecksum,
UnsupportedVersion(u8),
InvalidZoomLevel(u8),
InvalidDimension(String),
Base64DecodeError,
ProjectionError(String),
IoError(String),
CsvError(String),
GeometryParseError(String),
ZoomLevelMismatch(u8, u8),
}
impl std::fmt::Display for N3gbError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
N3gbError::InvalidIdentifierLength => write!(f, "Invalid identifier length"),
N3gbError::InvalidChecksum => write!(f, "Invalid checksum"),
N3gbError::UnsupportedVersion(v) => write!(f, "Unsupported version: {}", v),
N3gbError::InvalidZoomLevel(z) => write!(f, "Invalid zoom level: {}", z),
N3gbError::InvalidDimension(msg) => write!(f, "Invalid dimension: {}", msg),
N3gbError::Base64DecodeError => write!(f, "Base64 decode error"),
N3gbError::ProjectionError(msg) => write!(f, "Projection error: {}", msg),
N3gbError::IoError(msg) => write!(f, "IO error: {}", msg),
N3gbError::CsvError(msg) => write!(f, "CSV error: {}", msg),
N3gbError::GeometryParseError(msg) => write!(f, "Geometry parse error: {}", msg),
N3gbError::ZoomLevelMismatch(a, b) => {
write!(f, "Zoom level mismatch: {} vs {}", a, b)
}
}
}
}
impl std::error::Error for N3gbError {}
impl From<std::io::Error> for N3gbError {
fn from(e: std::io::Error) -> Self {
N3gbError::IoError(e.to_string())
}
}
impl From<csv::Error> for N3gbError {
fn from(e: csv::Error) -> Self {
N3gbError::CsvError(e.to_string())
}
}
impl From<arrow_schema::ArrowError> for N3gbError {
fn from(e: arrow_schema::ArrowError) -> Self {
N3gbError::IoError(e.to_string())
}
}
impl From<parquet::errors::ParquetError> for N3gbError {
fn from(e: parquet::errors::ParquetError) -> Self {
N3gbError::IoError(e.to_string())
}
}