Skip to content

Commit f1405f9

Browse files
stereotype441Commit Queue
authored andcommitted
[linter] Improve error handling when processing messages.yaml file.
Adds some missing `$`s to fix string interpolation when reporting errors in the `messages.yaml` file. Also adds a try/catch so that if an error occurs while processing a particular lint code, the lint code in question will always be reported. This should make it easier to track down problems when working on the linter's `messages.yaml` file. Change-Id: I6a6a6964072522ac4f43579f28f8d190a0c794f1 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/451840 Auto-Submit: Paul Berry <[email protected]> Reviewed-by: Samuel Rawlins <[email protected]> Commit-Queue: Samuel Rawlins <[email protected]>
1 parent 79ae34c commit f1405f9

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

pkg/linter/tool/messages_info.dart

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ final Map<String, RuleInfo> messagesRuleInfo = () {
4747
var lintCodes = messagesYaml['LintCode'] as YamlMap?;
4848
if (lintCodes == null) {
4949
throw StateError(
50-
"The '_messagesFileName' file does not have a 'LintCode' section.",
50+
"The '$_messagesFileName' file does not have a 'LintCode' section.",
5151
);
5252
}
5353

@@ -57,7 +57,7 @@ final Map<String, RuleInfo> messagesRuleInfo = () {
5757
for (var i = 0; i < lintCodeKeys.length; i++) {
5858
if (lintCodeKeys[i] != lintCodeKeysSorted[i]) {
5959
throw StateError(
60-
"The LintCode entries in '_messagesFileName' "
60+
"The LintCode entries in '$_messagesFileName' "
6161
"are not sorted alphabetically, starting at '${lintCodeKeys[i]}'.",
6262
);
6363
}
@@ -77,7 +77,13 @@ final Map<String, RuleInfo> messagesRuleInfo = () {
7777
rule.addEntry(uniqueName, data);
7878
}
7979

80-
return builders.map((key, value) => MapEntry(key, value.build()));
80+
return builders.map((key, value) {
81+
try {
82+
return MapEntry(key, value.build());
83+
} catch (e, st) {
84+
Error.throwWithStackTrace('Problem with lint code $key: $e', st);
85+
}
86+
});
8187
}();
8288

8389
final String _messagesYamlPath = pathRelativeToPackageRoot(['messages.yaml']);

0 commit comments

Comments
 (0)