Skip to content

Commit

Permalink
Remove period from error messages for consistency and rephrase some m…
Browse files Browse the repository at this point in the history
…essages
  • Loading branch information
Mingun committed May 8, 2022
1 parent 149635a commit 6b82fc3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
18 changes: 10 additions & 8 deletions src/errors.rs
Expand Up @@ -27,13 +27,15 @@ pub enum Error {
TextNotFound,
/// `Event::XmlDecl` must start with *version* attribute
XmlDeclWithoutVersion(Option<String>),
/// 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),
Expand Down Expand Up @@ -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)
}
Expand All @@ -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!(
Expand Down
2 changes: 1 addition & 1 deletion 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(
Expand Down
4 changes: 2 additions & 2 deletions tests/xmlrs_reader_tests.rs
Expand Up @@ -161,7 +161,7 @@ fn sample_ns_short() {
fn eof_1() {
test(
r#"<?xml"#,
r#"Error: Unexpected EOF during reading XmlDecl."#,
r#"Error: Unexpected EOF during reading XmlDecl"#,
true,
);
}
Expand All @@ -170,7 +170,7 @@ fn eof_1() {
fn bad_1() {
test(
r#"<?xml&.,"#,
r#"1:6 Error: Unexpected EOF during reading XmlDecl."#,
r#"1:6 Error: Unexpected EOF during reading XmlDecl"#,
true,
);
}
Expand Down

0 comments on commit 6b82fc3

Please sign in to comment.