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

Unified Diff: Source/bindings/v8/ExceptionMessages.cpp

Issue 38063003: Improve TypeError messages from failed array conversions. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 2 months 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
Index: Source/bindings/v8/ExceptionMessages.cpp
diff --git a/Source/bindings/v8/ExceptionMessages.cpp b/Source/bindings/v8/ExceptionMessages.cpp
index e1d879fe97f450f8c8da47fa431fbe2bdd4aeb59..d317e91021fda6e259da465d38d971cfca173033 100644
--- a/Source/bindings/v8/ExceptionMessages.cpp
+++ b/Source/bindings/v8/ExceptionMessages.cpp
@@ -58,9 +58,39 @@ String ExceptionMessages::failedToDelete(const String& property, const String& t
return "Failed to delete the '" + property + "' property from '" + type + "': " + detail;
}
-String ExceptionMessages::notASequenceType(const String& argument)
+String ExceptionMessages::notASequenceType(int argumentIndex)
{
- return argument + " argument is neither an array, nor does it have indexed properties.";
+ String kind(" argument");
+
+ String prefix;
+ switch (argumentIndex) {
+ case 1:
+ prefix = "First";
+ break;
+ case 2:
+ prefix = "Second";
+ break;
+ case 3:
+ prefix = "Third";
+ break;
+ default:
+ if (argumentIndex <= 0)
+ kind = "Value";
+ else
+ prefix = String::number(argumentIndex) + "th";
+ break;
+ }
Mike West 2013/10/24 07:08:54 I've avoided this in other places by phrasing it a
sof 2013/10/24 21:16:41 I prefer "Second argument" (or "2nd argument") ove
+ return prefix + kind + " is neither an array, nor does it have indexed properties.";
+}
+
+String ExceptionMessages::notASequenceType(const String& argument, const String& kind)
+{
+ String prefix;
+ if (kind.isEmpty())
+ prefix = argument + " argument";
+ else
+ prefix = "'" + argument + "' " + kind;
+ return prefix + " is neither an array, nor does it have indexed properties.";
}
String ExceptionMessages::notEnoughArguments(unsigned expected, unsigned provided)

Powered by Google App Engine
This is Rietveld 408576698