style: Add a new CSS error type for lone value parsing errors.

This allows us to report errors in functions that want to just parse a
single CSS value, rather than a value for a particular property declaration.

The one value type that we need to support for now is <color> value parsing
errors, so just add formatting/support for that.
This commit is contained in:
Cameron McCormack 2017-12-04 12:52:39 +08:00
parent 7940061c9a
commit 7015d5b22e
2 changed files with 28 additions and 2 deletions

View file

@ -46,6 +46,8 @@ pub enum ContextualParseError<'a> {
InvalidCounterStyleExtendsWithAdditiveSymbols,
/// A media rule was invalid for some reason.
InvalidMediaRule(&'a str, ParseError<'a>),
/// A value was not recognized.
UnsupportedValue(&'a str, ParseError<'a>),
}
impl<'a> fmt::Display for ContextualParseError<'a> {
@ -173,6 +175,9 @@ impl<'a> fmt::Display for ContextualParseError<'a> {
write!(f, "Invalid media rule: {}, ", media_rule)?;
parse_error_to_str(err, f)
}
ContextualParseError::UnsupportedValue(_value, ref err) => {
parse_error_to_str(err, f)
}
}
}
}