use rdom_style::property_dispatch::DispatchError;
#[derive(Debug)]
#[non_exhaustive]
pub enum SetPropertyError {
Parse(DispatchError),
Tree(rdom_core::DomError),
}
impl From<DispatchError> for SetPropertyError {
fn from(e: DispatchError) -> Self {
Self::Parse(e)
}
}
impl From<rdom_core::DomError> for SetPropertyError {
fn from(e: rdom_core::DomError) -> Self {
Self::Tree(e)
}
}
impl core::fmt::Display for SetPropertyError {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Self::Parse(DispatchError::UnknownProperty) => {
write!(f, "unknown CSS property")
}
Self::Parse(DispatchError::InvalidValue) => {
write!(f, "invalid value for property")
}
Self::Parse(e) => write!(f, "CSS parse error: {e:?}"),
Self::Tree(e) => write!(f, "DOM tree error: {e:?}"),
}
}
}
impl std::error::Error for SetPropertyError {}