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

Side by Side 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 String ExceptionMessages::failedToSet(const String& property, const String& type , const String& detail) 51 String ExceptionMessages::failedToSet(const String& property, const String& type , const String& detail)
52 { 52 {
53 return "Failed to set the '" + property + "' property on '" + type + "': " + detail; 53 return "Failed to set the '" + property + "' property on '" + type + "': " + detail;
54 } 54 }
55 55
56 String ExceptionMessages::failedToDelete(const String& property, const String& t ype, const String& detail) 56 String ExceptionMessages::failedToDelete(const String& property, const String& t ype, const String& detail)
57 { 57 {
58 return "Failed to delete the '" + property + "' property from '" + type + "' : " + detail; 58 return "Failed to delete the '" + property + "' property from '" + type + "' : " + detail;
59 } 59 }
60 60
61 String ExceptionMessages::notASequenceType(const String& argument) 61 String ExceptionMessages::notASequenceType(int argumentIndex)
62 { 62 {
63 return argument + " argument is neither an array, nor does it have indexed p roperties."; 63 String kind(" argument");
64
65 String prefix;
66 switch (argumentIndex) {
67 case 1:
68 prefix = "First";
69 break;
70 case 2:
71 prefix = "Second";
72 break;
73 case 3:
74 prefix = "Third";
75 break;
76 default:
77 if (argumentIndex <= 0)
78 kind = "Value";
79 else
80 prefix = String::number(argumentIndex) + "th";
81 break;
82 }
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
83 return prefix + kind + " is neither an array, nor does it have indexed prope rties.";
84 }
85
86 String ExceptionMessages::notASequenceType(const String& argument, const String& kind)
87 {
88 String prefix;
89 if (kind.isEmpty())
90 prefix = argument + " argument";
91 else
92 prefix = "'" + argument + "' " + kind;
93 return prefix + " is neither an array, nor does it have indexed properties." ;
64 } 94 }
65 95
66 String ExceptionMessages::notEnoughArguments(unsigned expected, unsigned provide d) 96 String ExceptionMessages::notEnoughArguments(unsigned expected, unsigned provide d)
67 { 97 {
68 return String::number(expected) + " argument" + (expected > 1 ? "s" : "") + " required, but only " + String::number(provided) + " present."; 98 return String::number(expected) + " argument" + (expected > 1 ? "s" : "") + " required, but only " + String::number(provided) + " present.";
69 } 99 }
70 100
71 } // namespace WebCore 101 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698