use core::fmt;
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub enum AstCoreError {
StaleHandle {
slot: u32,
expected: u32,
found: u32,
},
UnknownSlot {
slot: u32,
},
Exhausted,
MalformedSnapshot {
offset: usize,
expected: &'static str,
},
CommitRejected {
reason: &'static str,
},
}
impl fmt::Display for AstCoreError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::StaleHandle {
slot,
expected,
found,
} => write!(
f,
"stale handle: slot {slot} carried generation {expected}, arena is at {found}"
),
Self::UnknownSlot { slot } => write!(f, "unknown arena slot {slot}"),
Self::Exhausted => write!(f, "arena or identity space exhausted"),
Self::MalformedSnapshot { offset, expected } => {
write!(
f,
"malformed snapshot at byte {offset}: expected {expected}"
)
}
Self::CommitRejected { reason } => write!(f, "commit rejected: {reason}"),
}
}
}
impl core::error::Error for AstCoreError {}