Skip to content

Commit 6fd836d

Browse files
committed
Ruby: improve wording of error messages
1 parent 51f34eb commit 6fd836d

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

ruby/extractor/src/extractor.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,15 +306,20 @@ impl<'a> Visitor<'a> {
306306
fn enter_node(&mut self, node: Node) -> bool {
307307
if node.is_missing() {
308308
self.record_parse_error_for_node(
309-
"parse error: expecting {}",
310-
&[node.kind()],
309+
"A parse error occurred, expecting {} symbol. Check the syntax of the file using the {} command. If the file is indeed invalid, please correct the error or exclude the file from analysis.",
310+
&[node.kind(), "ruby -c"],
311311
node,
312312
true,
313313
);
314314
return false;
315315
}
316316
if node.is_error() {
317-
self.record_parse_error_for_node("parse error", &[], node, true);
317+
self.record_parse_error_for_node(
318+
"A parse error occurred. Check the syntax of the file using the {} command. If the file is indeed invalid, please correct the error or exclude the file from analysis.",
319+
&["ruby -c"],
320+
node,
321+
true,
322+
);
318323
return false;
319324
};
320325

ruby/extractor/src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,8 @@ fn main() -> std::io::Result<()> {
203203
)
204204
.file(&path.to_string_lossy())
205205
.message(
206-
"could not decode the file contents as {}: {}",
207-
&[&encoding_name, &msg],
206+
"Could not decode the file contents as {}: {}. Validate that the contents of the file matches the character encoding specified in the {} directive at the top of the file.",
207+
&[&encoding_name, &msg, "encoding:"],
208208
)
209209
.status_page()
210210
.severity(diagnostics::Severity::Warning),
@@ -218,7 +218,7 @@ fn main() -> std::io::Result<()> {
218218
.new_entry("unknown-character-encoding", "Unknown character encoding")
219219
.file(&path.to_string_lossy())
220220
.message(
221-
"unknown character encoding {} in {} directive.",
221+
"Unknown character encoding {} in {} directive. Validate that the specified name is a supported character set.",
222222
&[&encoding_name, "#encoding:"],
223223
)
224224
.status_page()
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
| src/not_ruby.rb:5:25:5:26 | parse error | Extraction failed in src/not_ruby.rb with error parse error | 2 |
2-
| src/unsupported_feature.rb:2:1:2:4 | parse error | Extraction failed in src/unsupported_feature.rb with error parse error | 2 |
3-
| src/unsupported_feature.rb:3:1:3:8 | parse error | Extraction failed in src/unsupported_feature.rb with error parse error | 2 |
1+
| src/not_ruby.rb:5:25:5:26 | A parse error occured. Check the syntax of the file using the ruby -c command. If the file is invalid, please correct the error or exclude the file from analysis. | Extraction failed in src/not_ruby.rb with error A parse error occured. Check the syntax of the file using the ruby -c command. If the file is invalid, please correct the error or exclude the file from analysis. | 2 |
2+
| src/unsupported_feature.rb:2:1:2:4 | A parse error occured. Check the syntax of the file using the ruby -c command. If the file is invalid, please correct the error or exclude the file from analysis. | Extraction failed in src/unsupported_feature.rb with error A parse error occured. Check the syntax of the file using the ruby -c command. If the file is invalid, please correct the error or exclude the file from analysis. | 2 |
3+
| src/unsupported_feature.rb:3:1:3:8 | A parse error occured. Check the syntax of the file using the ruby -c command. If the file is invalid, please correct the error or exclude the file from analysis. | Extraction failed in src/unsupported_feature.rb with error A parse error occured. Check the syntax of the file using the ruby -c command. If the file is invalid, please correct the error or exclude the file from analysis. | 2 |

0 commit comments

Comments
 (0)