use geometry_io_wkb::WkbError;
#[derive(Debug, Clone, PartialEq)]
pub enum EwkbError {
BoundingBoxFlag {
type_word: u32,
},
TruncatedSrid {
type_word: u32,
},
DimensionFlag {
type_word: u32,
},
InvalidHex {
index: usize,
},
Wkb(WkbError),
}
impl From<WkbError> for EwkbError {
fn from(error: WkbError) -> Self {
Self::Wkb(error)
}
}
impl core::fmt::Display for EwkbError {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
EwkbError::BoundingBoxFlag { type_word } => write!(
f,
"type word {type_word:#010x} sets the bounding-box flag: \
this reader does not skip a bounding box"
),
EwkbError::TruncatedSrid { type_word } => write!(
f,
"type word {type_word:#010x} sets the SRID flag but fewer \
than four bytes follow it"
),
EwkbError::DimensionFlag { type_word } => write!(
f,
"type word {type_word:#010x} sets the Z or M flag: \
this reader is 2D only"
),
EwkbError::InvalidHex { index } => {
write!(f, "invalid hex input at byte {index}")
}
EwkbError::Wkb(e) => write!(f, "invalid WKB body: {e}"),
}
}
}
#[cfg(feature = "std")]
impl std::error::Error for EwkbError {}