-
Federico Mena Quintero authored
Our terminology for errors is slightly wrong, and it doesn't quite match the model that rust-cssparser and servo expect. Rust-cssparser provides BasicParseError, which is a BasicParseErrorKind plus a location. This is just a simple parsing error like "unexpected token" or "premature EOF". On top of that, rust-cssparser provides ParseError and ParseErrorKind. The former is a ParseErrorKind plus a location; the latter is a basic parse error, or a custom error. When implementing the rules_and_declarations traits, cssparser expects us to provide our own custom parsing errors in the form of ParseError<OurCustomError>. For example, Servo has this: pub type ParseError<'i> = cssparser::ParseError<'i, StyleParseErrorKind<'i>>; And that StyleParseErrorKind has a ton of stuff: pub enum StyleParseErrorKind<'i> { BadUrlInDeclarationValueBlock(CowRcStr<'i>), BadStringInDeclarationValueBlock(CowRcStr<'i>), UnbalancedCloseParenthesisInDeclarationValueBlock, UnbalancedCloseSquareBracketInDeclarationValueBlock, UnbalancedCloseCurlyBracketInDeclarationValueBlock, PropertyDeclarationValueNotExhausted, UnexpectedDimension(CowRcStr<'i>), ... } So, we will move to a similar model. AttributeError is the wrong name; it represents a parsing or validation error in a value from an element attribute, or a CSS style property... but we don't know which. Instead, we'll call it ValueErrorKind, to make it closer to rust-cssparser's view of the world.
7e629ca9