#[derive(Debug, Clone)]
pub enum TransformationNormalError {
InvalidInput { reason: String },
DesignDegenerate { reason: String },
NonFinite { reason: String },
MonotonicityViolated { reason: String },
NumericalFailure { reason: String },
}
impl std::fmt::Display for TransformationNormalError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
TransformationNormalError::InvalidInput { reason }
| TransformationNormalError::DesignDegenerate { reason }
| TransformationNormalError::NonFinite { reason }
| TransformationNormalError::MonotonicityViolated { reason }
| TransformationNormalError::NumericalFailure { reason } => f.write_str(reason),
}
}
}
impl std::error::Error for TransformationNormalError {}
impl From<TransformationNormalError> for String {
fn from(err: TransformationNormalError) -> String {
err.to_string()
}
}
impl From<crate::util::block_count::BlockCountMismatch> for TransformationNormalError {
fn from(err: crate::util::block_count::BlockCountMismatch) -> TransformationNormalError {
TransformationNormalError::InvalidInput {
reason: err.message(),
}
}
}