#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("calculated segment of loss function is too short")]
NotEnoughPoints,
#[error("calculation didn't return any segments")]
NoSegmentsFound,
}
#[cfg(feature = "rayon")]
impl Error {
pub(crate) const fn into_error_u8(self) -> u8 {
match self {
Self::NotEnoughPoints => 1,
Self::NoSegmentsFound => 2,
}
}
#[allow(clippy::panic_in_result_fn)]
pub(crate) const fn try_from_u8(error_number: u8) -> Result<(), Self> {
match error_number {
0 => Ok(()),
1 => Err(Self::NotEnoughPoints),
2 => Err(Self::NoSegmentsFound),
_ => panic!("Unrecognized error number"),
}
}
}