mirror of
https://github.com/servo/servo.git
synced 2025-06-29 03:23:41 +01:00
Factor out parsing of various types of rules.
This commit is contained in:
parent
ff1f4e62ec
commit
9b22acf2f3
5 changed files with 152 additions and 104 deletions
26
errors.rs
Normal file
26
errors.rs
Normal file
|
@ -0,0 +1,26 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use cssparser::{SyntaxError, SourceLocation};
|
||||
|
||||
|
||||
pub struct ErrorLoggerIterator<I>(I);
|
||||
|
||||
impl<T, I: Iterator<Result<T, SyntaxError>>> Iterator<T> for ErrorLoggerIterator<I> {
|
||||
pub fn next(&mut self) -> Option<T> {
|
||||
for result in **self {
|
||||
match result {
|
||||
Ok(v) => return Some(v),
|
||||
Err(error) => log_css_error(error.location, fmt!("%?", error.reason))
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pub fn log_css_error(location: SourceLocation, message: &str) {
|
||||
// TODO eventually this will got into a "web console" or something.
|
||||
info!("%u:%u %s", location.line, location.column, message)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue