mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-28 04:35:33 +00:00
a17272e07f
Source-Repo: https://github.com/servo/servo Source-Revision: 3809e4a23dc1423caa78385d2bfa0ea4d6eabbcb
28 lines
964 B
Rust
28 lines
964 B
Rust
/* 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/. */
|
|
|
|
//! Types used to report parsing errors.
|
|
|
|
use cssparser::{Parser, SourcePosition};
|
|
use log;
|
|
|
|
pub trait ParseErrorReporter {
|
|
fn report_error(&self, input: &mut Parser, position: SourcePosition, message: &str);
|
|
fn clone(&self) -> Box<ParseErrorReporter + Send + Sync>;
|
|
}
|
|
|
|
pub struct StdoutErrorReporter;
|
|
impl ParseErrorReporter for StdoutErrorReporter {
|
|
fn report_error(&self, input: &mut Parser, position: SourcePosition, message: &str) {
|
|
if log_enabled!(log::LogLevel::Info) {
|
|
let location = input.source_location(position);
|
|
info!("{}:{} {}", location.line, location.column, message)
|
|
}
|
|
}
|
|
|
|
fn clone(&self) -> Box<ParseErrorReporter + Send + Sync> {
|
|
Box::new(StdoutErrorReporter)
|
|
}
|
|
}
|