use core::fmt;
use std::error::Error;
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
pub enum ParseError {
InvalidLength,
NodeCapacityExceeded,
StackCapacityExceeded,
RootCapacityExceeded,
AttributeCapacityExceeded,
ChildCapacityExceeded,
IdCapacityExceeded,
ClassCapacityExceeded,
SelectorCapacityExceeded,
UnsupportedAssemblySyntax,
}
impl fmt::Display for ParseError {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
match self {
ParseError::InvalidLength => {
write!(f, "The input string length is too large to fit in a `u32`")
}
ParseError::NodeCapacityExceeded => {
write!(f, "The configured node capacity was exceeded")
}
ParseError::StackCapacityExceeded => {
write!(f, "The configured stack capacity was exceeded")
}
ParseError::RootCapacityExceeded => {
write!(f, "The configured root-node capacity was exceeded")
}
ParseError::AttributeCapacityExceeded => {
write!(f, "The configured attribute capacity was exceeded")
}
ParseError::ChildCapacityExceeded => {
write!(f, "The configured child capacity was exceeded")
}
ParseError::IdCapacityExceeded => {
write!(f, "The configured ID index capacity was exceeded")
}
ParseError::ClassCapacityExceeded => {
write!(f, "The configured class index capacity was exceeded")
}
ParseError::SelectorCapacityExceeded => {
write!(f, "The configured query selector capacity was exceeded")
}
ParseError::UnsupportedAssemblySyntax => {
write!(
f,
"The input uses syntax outside of the current assembly parser milestone"
)
}
}
}
}
impl Error for ParseError {}
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
pub enum SetBytesError {
LengthOverflow,
}
impl fmt::Display for SetBytesError {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
match self {
SetBytesError::LengthOverflow => {
write!(f, "The string length is too large to fit in a `u32`")
}
}
}
}
impl Error for SetBytesError {}