Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(430)

Unified Diff: pkg/intl/lib/src/intl_message.dart

Issue 720903003: Better error message for mismatched parameter names between message and translation (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/intl/CHANGELOG.md ('k') | pkg/intl/pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/intl/lib/src/intl_message.dart
diff --git a/pkg/intl/lib/src/intl_message.dart b/pkg/intl/lib/src/intl_message.dart
index 97eb48ed2a3a1c88ee3a0fc031f234b5a4448055..8bb9fdb4805eb8531631e244d963d5eb8542d525 100644
--- a/pkg/intl/lib/src/intl_message.dart
+++ b/pkg/intl/lib/src/intl_message.dart
@@ -69,6 +69,11 @@ abstract class Message {
*/
get examples => parent == null ? const [] : parent.examples;
+ /**
+ * The name of the top-level [MainMessage].
+ */
+ String get name => parent == null ? '<unnamed>' : parent.name;
+
String checkValidity(MethodInvocation node, List arguments,
String outerName, FormalParameterList outerArgs) {
var hasArgs = arguments.any(
@@ -274,6 +279,12 @@ class VariableSubstitution extends Message {
// case-insensitive.
_index = arguments.map((x) => x.toUpperCase()).toList()
.indexOf(_variableNameUpper);
+ if (_index == -1) {
+ throw new ArgumentError(
+ "Cannot find parameter named '$_variableNameUpper' in "
+ "message named '$name'. Available "
+ "parameters are $arguments");
+ }
return _index;
}
« no previous file with comments | « pkg/intl/CHANGELOG.md ('k') | pkg/intl/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698