use std::error::Error;
use std::fmt;
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum TraceError {
EmptyTrace,
InvalidRange {
start_index: usize,
end_index: usize,
},
IndexOutOfBounds { index: usize, len: usize },
}
impl fmt::Display for TraceError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
TraceError::EmptyTrace => write!(f, "trace has no locations"),
TraceError::InvalidRange {
start_index,
end_index,
} => write!(
f,
"start_index ({start_index}) must be smaller than end_index ({end_index})"
),
TraceError::IndexOutOfBounds { index, len } => {
write!(f, "index {index} out of bounds for trace of length {len}")
}
}
}
}
impl Error for TraceError {}