Report CSS parse errors via enum instead of strings.

This commit is contained in:
Josh Matthews 2017-04-18 14:08:05 +10:00
parent e46aa87b4c
commit fd6e54d9e3
10 changed files with 124 additions and 65 deletions

View file

@ -7,6 +7,7 @@
use {Namespace, Prefix};
use counter_style::{parse_counter_style_body, parse_counter_style_name};
use cssparser::{AtRuleParser, AtRuleType, Parser, QualifiedRuleParser, RuleListParser, SourceLocation};
use error_reporting::ParseError;
use font_face::parse_font_face_block;
use media_queries::{parse_media_query_list, MediaList};
use parking_lot::RwLock;
@ -304,8 +305,8 @@ impl<'a, 'b> NestedRuleParser<'a, 'b> {
Ok(rule) => rules.push(rule),
Err(range) => {
let pos = range.start;
let message = format!("Unsupported rule: '{}'", iter.input.slice(range));
log_css_error(iter.input, pos, &*message, self.context);
let error = ParseError::UnsupportedRule(iter.input.slice(range));
log_css_error(iter.input, pos, error, self.context);
}
}
}