Ruby: improve encoding related messages

This commit is contained in:
Arthur Baars
2023-02-16 13:11:22 +01:00
parent ecbd768df4
commit 006ee5aad9
2 changed files with 19 additions and 8 deletions

View File

@@ -198,14 +198,14 @@ fn main() -> std::io::Result<()> {
diagnostics_writer.write(
diagnostics_writer
.message(
"character-encoding-error",
"Character encoding error",
"character-decoding-error",
"Character decoding error",
)
.file(&path.to_string_lossy())
.text(&format!(
"{}: character decoding failure: {} ({})",
&path.to_string_lossy(),
"could not decode the file contents as '{}': {}",
&encoding_name,
msg,
&encoding_name
))
.status_page()
.severity(diagnostics::Severity::Warning),
@@ -216,13 +216,14 @@ fn main() -> std::io::Result<()> {
} else {
diagnostics_writer.write(
diagnostics_writer
.message("character-encoding-error", "Character encoding error")
.message("unknown-character-encoding", "Unknown character encoding")
.file(&path.to_string_lossy())
.text(&format!(
"{}: unknown character encoding: '{}'",
&path.to_string_lossy(),
"unknown character encoding '{}' in '#encoding:' directive.",
&encoding_name
))
.status_page()
.help_link("https://docs.ruby-lang.org/en/3.2/syntax/comments_rdoc.html#label-encoding+Directive")
.severity(diagnostics::Severity::Warning),
);
}