Skip to content
This repository has been archived by the owner on Mar 25, 2024. It is now read-only.

Eliminate repetitive line/column context from error message #294

Merged
merged 1 commit into from Jul 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/libyaml/error.rs
Expand Up @@ -72,7 +72,10 @@ impl Display for Error {
}
if let Some(context) = &self.context {
write!(formatter, ", {}", context)?;
if self.context_mark.sys.line != 0 || self.context_mark.sys.column != 0 {
if (self.context_mark.sys.line != 0 || self.context_mark.sys.column != 0)
&& (self.context_mark.sys.line != self.problem_mark.sys.line
|| self.context_mark.sys.column != self.problem_mark.sys.column)
{
write!(formatter, " at {}", self.context_mark)?;
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/test_error.rs
Expand Up @@ -132,7 +132,7 @@ fn test_second_document_syntax_error() {

let second_doc = de.next().unwrap();
let result = <usize as serde::Deserialize>::deserialize(second_doc);
let expected = "did not find expected node content at line 4 column 1, while parsing a block node at line 4 column 1";
let expected = "did not find expected node content at line 4 column 1, while parsing a block node";
assert_eq!(expected, result.unwrap_err().to_string());
}

Expand Down