#[non_exhaustive]pub enum ClimateError {
ShapeMismatch {
argument: &'static str,
expected: usize,
actual: usize,
},
EmptyPeriod {
argument: &'static str,
},
NonFinite {
index_type: &'static str,
},
IndexOutOfRange {
argument: &'static str,
value: i64,
minimum: i64,
maximum: i64,
},
UnknownNanPolicy {
value: String,
},
RowsOutOfRange {
argument: &'static str,
start: usize,
end: usize,
length: usize,
},
NoConvergence {
message: &'static str,
},
InsufficientData {
required: usize,
available: usize,
},
}Expand description
A structural input error or a numerical failure reported by a kernel.
Variants and their typed fields form the error contract. Diagnostic strings,
including Display output, are not stable identifiers.
use climate_indices::{ClimateError, flood::effective_precipitation};
use ndarray::array;
let rain = array![[1.0]];
match effective_precipitation(rain.view(), 0) {
Err(ClimateError::EmptyPeriod { argument }) => assert_eq!(argument, "duration"),
Err(_) => panic!("unexpected error"),
Ok(_) => panic!("a zero-day window must fail"),
}Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
ShapeMismatch
An argument whose shape does not match the kernel’s expected shape.
Fields
EmptyPeriod
A calendar-period parameter with no calendar steps.
NonFinite
A recurrence step produced a non-finite value from finite inputs.
IndexOutOfRange
A per-day or per-cell index outside the table it selects from.
Fields
UnknownNanPolicy
A missing-day policy name a kernel does not implement.
RowsOutOfRange
A row window (a Calibration Period) that does not lie inside its axis.
Fields
NoConvergence
A calibration or recurrence stage that cannot produce a usable value.
InsufficientData
A series too short (or too sparse) to fill a rolling window.
Trait Implementations§
Source§impl Clone for ClimateError
impl Clone for ClimateError
Source§impl Debug for ClimateError
impl Debug for ClimateError
Source§impl Display for ClimateError
impl Display for ClimateError
impl Eq for ClimateError
Source§impl Error for ClimateError
impl Error for ClimateError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0:
use the Display impl or to_string()
Source§impl PartialEq for ClimateError
impl PartialEq for ClimateError
impl StructuralPartialEq for ClimateError
Auto Trait Implementations§
impl Freeze for ClimateError
impl RefUnwindSafe for ClimateError
impl Send for ClimateError
impl Sync for ClimateError
impl Unpin for ClimateError
impl UnsafeUnpin for ClimateError
impl UnwindSafe for ClimateError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more