use std::fmt;
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
pub enum Fault {
DivisionByZero,
Limit,
}
impl fmt::Display for Fault {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(match self {
Fault::DivisionByZero => "division by zero",
Fault::Limit => "the result's exponent does not fit in 64 bits",
})
}
}
impl std::error::Error for Fault {}
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
pub enum DataError {
NotData,
Mismatch,
}
impl fmt::Display for DataError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(match self {
DataError::NotData => "the value is not data",
DataError::Mismatch => "the values are not of one type",
})
}
}
impl std::error::Error for DataError {}
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
pub enum StructureError {
Leaf,
End,
Window,
Run,
}
impl fmt::Display for StructureError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(match self {
StructureError::Leaf => "a leaf holds from one to eight elements",
StructureError::End => "a list's end holds at most eight elements",
StructureError::Window => "a list takes elements its tree does not hold",
StructureError::Run => "a run does not lie between characters of its block",
})
}
}
impl std::error::Error for StructureError {}