aboutsummaryrefslogtreecommitdiff
path: root/src/tokenizer/error.rs
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2021-11-30 10:56:59 +0100
committerMartin Fischer <martin@push-f.com>2021-11-30 11:22:35 +0100
commit915530c02029f8bd4444930ed949e14f09afab03 (patch)
tree6f58b9728386dc5c1709137bc0a250640a7ce572 /src/tokenizer/error.rs
parent414e5838618123cb00216a7426b898aab88ee45a (diff)
report spans for errors
Diffstat (limited to 'src/tokenizer/error.rs')
-rw-r--r--src/tokenizer/error.rs9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/tokenizer/error.rs b/src/tokenizer/error.rs
index 0acc88f..dad3fd2 100644
--- a/src/tokenizer/error.rs
+++ b/src/tokenizer/error.rs
@@ -6,7 +6,12 @@ use std::fmt::Display;
pub enum Error {
AttributesOnEndTag,
SelfClosingEndTag,
- DuplicateAttribute,
+ DuplicateAttribute {
+ #[cfg(feature = "spans")]
+ #[cfg_attr(docsrs, doc(cfg(feature = "spans")))]
+ /// Span of the duplicate attribute name.
+ span: std::ops::Range<usize>,
+ },
BadCharacter(char),
UnexpectedCharacter(char, InternalState),
UnexpectedEOF(InternalState),
@@ -22,7 +27,7 @@ impl Display for Error {
match self {
Error::AttributesOnEndTag => write!(f, "attributes on an end tag"),
Error::SelfClosingEndTag => write!(f, "self-closing end tag"),
- Error::DuplicateAttribute => write!(f, "duplicate attribute"),
+ Error::DuplicateAttribute { .. } => write!(f, "duplicate attribute"),
Error::BadCharacter(char) => write!(f, "bad character {:?}", char),
Error::UnexpectedCharacter(char, state) => {
write!(