use std::fmt;
#[derive(Debug, Clone, Copy, PartialEq)]
#[non_exhaustive]
pub enum GridError {
EmptyDimensions {
nx: usize,
ny: usize,
},
CellCountOverflow {
nx: usize,
ny: usize,
},
InvalidSpacing {
dx: f64,
dy: f64,
},
}
impl fmt::Display for GridError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::EmptyDimensions { nx, ny } => write!(
f,
"invalid grid dimensions nx={nx}, ny={ny}: use nonzero dimensions"
),
Self::CellCountOverflow { nx, ny } => write!(
f,
"grid cell count overflows for nx={nx}, ny={ny}: reduce dimensions"
),
Self::InvalidSpacing { dx, dy } => write!(
f,
"invalid grid spacing dx={dx}, dy={dy}: use finite positive spacing with representable area and extents"
),
}
}
}
impl std::error::Error for GridError {}