Skip to main content

hjkl_css/
error.rs

1use thiserror::Error;
2
3/// Failure modes for [`crate::parse`]. The current implementation is
4/// lenient — malformed rules and declarations are dropped silently per
5/// CSS spec, so a normal `parse` call never returns this. The type is
6/// preserved on the public API so a future strict-mode entry point can
7/// surface diagnostics without a breaking change.
8#[derive(Debug, Error)]
9#[non_exhaustive]
10pub enum ParseError {
11    #[error("CSS syntax error at line {line}, col {column}: {message}")]
12    Syntax {
13        line: u32,
14        column: u32,
15        message: String,
16    },
17}
18
19/// Internal error type for the cssparser parser plumbing: the message of a
20/// custom `cssparser::ParseError`. Not part of the public API — `parse`
21/// drops every rule and declaration error, so it never leaves the crate.
22#[derive(Debug, Clone, PartialEq, Eq)]
23pub(crate) struct ParseErrorOwned(pub String);