#[non_exhaustive]pub enum Error {
Parse {
kind: ParseErrorKind,
offset: usize,
},
Unsupported {
construct: String,
offset: Option<usize>,
},
}Expand description
Why a CSS selector could not be translated.
The variants split by whose rules were broken: Error::Parse for
a selector CSS itself rejects, Error::Unsupported for a valid
selector this crate declines to approximate.
A Error::Parse always knows the offending byte position, so it
always renders a caret. A Error::Unsupported knows one for the
constructs the pre-parse scan of the source text finds, and not for
the ones the translator finds, because Servo’s parsed components
carry no source offsets to map a component back to the selector
text. Its offset is therefore an Option, and its message grows
a caret only when it is Some.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Parse
The selector is not valid CSS (as judged by Servo’s parser).
Fields
kind: ParseErrorKindWhat is wrong with the selector.
Unsupported
The selector is valid CSS, but uses a construct outside the supported set: this crate errors rather than approximating.
Implementations§
Source§impl Error
impl Error
Sourcepub fn message(&self, selector: &str) -> String
pub fn message(&self, selector: &str) -> String
Render the full user-facing message, naming the offending selector — and, whenever the error carries a position, pointing a caret at it.
Display is the one-line form for callers
that no longer hold the selector; this is the form to print when
they do.
Sourcepub fn into_message(self, selector: &str) -> String
👎Deprecated since 0.3.0: use Error::message, which takes &self
pub fn into_message(self, selector: &str) -> String
use Error::message, which takes &self
Deprecated alias for Error::message, which borrows the error
rather than consuming it.
Trait Implementations§
impl Eq for Error
Source§impl Error for Error
impl Error for Error
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()