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

Side by Side Diff: Source/bindings/v8/ExceptionMessages.cpp

Issue 351423002: Moved files under Source/bindings/v8 to Source/bindings/core/v8. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « Source/bindings/v8/ExceptionMessages.h ('k') | Source/bindings/v8/ExceptionState.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 #include "config.h"
32 #include "bindings/v8/ExceptionMessages.h"
33
34 #include "platform/Decimal.h"
35 #include "wtf/MathExtras.h"
36
37 namespace WebCore {
38
39 String ExceptionMessages::failedToConstruct(const char* type, const String& deta il)
40 {
41 return "Failed to construct '" + String(type) + (!detail.isEmpty() ? String( "': " + detail) : String("'"));
42 }
43
44 String ExceptionMessages::failedToEnumerate(const char* type, const String& deta il)
45 {
46 return "Failed to enumerate the properties of '" + String(type) + (!detail.i sEmpty() ? String("': " + detail) : String("'"));
47 }
48
49 String ExceptionMessages::failedToExecute(const char* method, const char* type, const String& detail)
50 {
51 return "Failed to execute '" + String(method) + "' on '" + String(type) + (! detail.isEmpty() ? String("': " + detail) : String("'"));
52 }
53
54 String ExceptionMessages::failedToGet(const char* property, const char* type, co nst String& detail)
55 {
56 return "Failed to read the '" + String(property) + "' property from '" + Str ing(type) + "': " + detail;
57 }
58
59 String ExceptionMessages::failedToSet(const char* property, const char* type, co nst String& detail)
60 {
61 return "Failed to set the '" + String(property) + "' property on '" + String (type) + "': " + detail;
62 }
63
64 String ExceptionMessages::failedToDelete(const char* property, const char* type, const String& detail)
65 {
66 return "Failed to delete the '" + String(property) + "' property from '" + S tring(type) + "': " + detail;
67 }
68
69 String ExceptionMessages::failedToGetIndexed(const char* type, const String& det ail)
70 {
71 return "Failed to read an indexed property from '" + String(type) + "': " + detail;
72 }
73
74 String ExceptionMessages::failedToSetIndexed(const char* type, const String& det ail)
75 {
76 return "Failed to set an indexed property on '" + String(type) + "': " + det ail;
77 }
78
79 String ExceptionMessages::failedToDeleteIndexed(const char* type, const String& detail)
80 {
81 return "Failed to delete an indexed property from '" + String(type) + "': " + detail;
82 }
83
84 String ExceptionMessages::constructorNotCallableAsFunction(const char* type)
85 {
86 return failedToConstruct(type, "Please use the 'new' operator, this DOM obje ct constructor cannot be called as a function.");
87 }
88
89 String ExceptionMessages::incorrectPropertyType(const String& property, const St ring& detail)
90 {
91 return "The '" + property + "' property " + detail;
92 }
93
94 String ExceptionMessages::invalidArity(const char* expected, unsigned provided)
95 {
96 return "Valid arities are: " + String(expected) + ", but " + String::number( provided) + " arguments provided.";
97 }
98
99 String ExceptionMessages::argumentNullOrIncorrectType(int argumentIndex, const S tring& expectedType)
100 {
101 return "The " + ordinalNumber(argumentIndex) + " argument provided is either null, or an invalid " + expectedType + " object.";
102 }
103
104 String ExceptionMessages::notAnArrayTypeArgumentOrValue(int argumentIndex)
105 {
106 String kind;
107 if (argumentIndex) // method argument
108 kind = ordinalNumber(argumentIndex) + " argument";
109 else // value, e.g. attribute setter
110 kind = "value provided";
111 return "The " + kind + " is neither an array, nor does it have indexed prope rties.";
112 }
113
114 String ExceptionMessages::notASequenceTypeProperty(const String& propertyName)
115 {
116 return "'" + propertyName + "' property is neither an array, nor does it hav e indexed properties.";
117 }
118
119 String ExceptionMessages::notEnoughArguments(unsigned expected, unsigned provide d)
120 {
121 return String::number(expected) + " argument" + (expected > 1 ? "s" : "") + " required, but only " + String::number(provided) + " present.";
122 }
123
124 String ExceptionMessages::notAFiniteNumber(double value, const char* name)
125 {
126 ASSERT(!std::isfinite(value));
127 return String::format("The %s is %s.", name, std::isinf(value) ? "infinite" : "not a number");
128 }
129
130 String ExceptionMessages::notAFiniteNumber(const Decimal& value, const char* nam e)
131 {
132 ASSERT(!value.isFinite());
133 return String::format("The %s is %s.", name, value.isInfinity() ? "infinite" : "not a number");
134 }
135
136 String ExceptionMessages::ordinalNumber(int number)
137 {
138 String suffix("th");
139 switch (number % 10) {
140 case 1:
141 if (number % 100 != 11)
142 suffix = "st";
143 break;
144 case 2:
145 if (number % 100 != 12)
146 suffix = "nd";
147 break;
148 case 3:
149 if (number % 100 != 13)
150 suffix = "rd";
151 break;
152 }
153 return String::number(number) + suffix;
154 }
155
156 String ExceptionMessages::readOnly(const char* detail)
157 {
158 DEFINE_STATIC_LOCAL(String, readOnly, ("This object is read-only."));
159 return detail ? String::format("This object is read-only, because %s.", deta il) : readOnly;
160 }
161
162 template <>
163 String ExceptionMessages::formatNumber<float>(float number)
164 {
165 return formatPotentiallyNonFiniteNumber(number);
166 }
167
168 template <>
169 String ExceptionMessages::formatNumber<double>(double number)
170 {
171 return formatPotentiallyNonFiniteNumber(number);
172 }
173
174 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/bindings/v8/ExceptionMessages.h ('k') | Source/bindings/v8/ExceptionState.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698