use blitz_dom::NodeId;
use crate::atom::AtomId;
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum DomError {
NodeNotFound(NodeId),
NoRootElement,
InvalidSelector(String),
InvalidClassToken(String),
UnknownAtom(AtomId),
TreeInvariant(&'static str),
}
impl std::fmt::Display for DomError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::NodeNotFound(id) => write!(f, "no node with id {id:?} in this document"),
Self::NoRootElement => write!(f, "document has no root element"),
Self::InvalidSelector(selector) => write!(f, "could not parse selector `{selector}`"),
Self::InvalidClassToken(token) => write!(
f,
"classList token `{token}` must be non-empty and contain no ASCII whitespace"
),
Self::UnknownAtom(atom) => write!(f, "{atom:?} was not produced by this interner"),
Self::TreeInvariant(what) => write!(f, "document tree invariant violated: {what}"),
}
}
}
impl std::error::Error for DomError {}