From 6b82fc3a17586af2f71e6c78e83ea49e90583669 Mon Sep 17 00:00:00 2001 From: Mingun Date: Mon, 11 Apr 2022 23:31:29 +0500 Subject: [PATCH] Remove period from error messages for consistency and rephrase some messages --- src/errors.rs | 18 ++++++++++-------- tests/documents/html5.txt | 2 +- tests/xmlrs_reader_tests.rs | 4 ++-- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/errors.rs b/src/errors.rs index 2860c49b..6c0dc743 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -27,13 +27,15 @@ pub enum Error { TextNotFound, /// `Event::XmlDecl` must start with *version* attribute XmlDeclWithoutVersion(Option), - /// Attribute Name contains quote + /// Attribute Name contains quote, position relative to start of owning tag is provided NameWithQuote(usize), - /// Attribute key not followed by with `=` + /// Attribute key not followed by with `=`, position relative to start of owning tag is provided NoEqAfterName(usize), - /// Attribute value not quoted + /// Attribute value not quoted, position relative to start of owning tag is provided UnquotedValue(usize), - /// Duplicate attribute + /// Duplicate attribute, positions relative to start of owning tag is provided: + /// - position of the duplicate + /// - previous position DuplicatedAttribute(usize, usize), /// Escape error EscapeError(EscapeError), @@ -73,7 +75,7 @@ impl std::fmt::Display for Error { match self { Error::Io(e) => write!(f, "I/O error: {}", e), Error::Utf8(e) => write!(f, "UTF8 error: {}", e), - Error::UnexpectedEof(e) => write!(f, "Unexpected EOF during reading {}.", e), + Error::UnexpectedEof(e) => write!(f, "Unexpected EOF during reading {}", e), Error::EndEventMismatch { expected, found } => { write!(f, "Expecting found ", expected, found) } @@ -92,19 +94,19 @@ impl std::fmt::Display for Error { Error::NameWithQuote(e) => write!( f, "error while parsing attribute at position {}: \ - Attribute key cannot contain quote.", + Attribute key cannot contain quote", e ), Error::NoEqAfterName(e) => write!( f, "error while parsing attribute at position {}: \ - Attribute key must be directly followed by = or space", + Attribute key must be directly followed by `=` or space", e ), Error::UnquotedValue(e) => write!( f, "error while parsing attribute at position {}: \ - Attribute value must start with a quote.", + Attribute value must start with a single or double quote", e ), Error::DuplicatedAttribute(pos1, pos2) => write!( diff --git a/tests/documents/html5.txt b/tests/documents/html5.txt index f1bc908b..df39548a 100644 --- a/tests/documents/html5.txt +++ b/tests/documents/html5.txt @@ -1,7 +1,7 @@ DocType(html) Characters( ) -StartElement(a, attr-error: error while parsing attribute at position 7: Attribute value must start with a quote.) +StartElement(a, attr-error: error while parsing attribute at position 7: Attribute value must start with a single or double quote) Characters(Hey) EndElement(a) Characters( diff --git a/tests/xmlrs_reader_tests.rs b/tests/xmlrs_reader_tests.rs index 25435c25..31e7d772 100644 --- a/tests/xmlrs_reader_tests.rs +++ b/tests/xmlrs_reader_tests.rs @@ -161,7 +161,7 @@ fn sample_ns_short() { fn eof_1() { test( r#"