OLD | NEW |
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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 return formatFiniteNumber(number); | 65 return formatFiniteNumber(number); |
66 } | 66 } |
67 | 67 |
68 static String incorrectPropertyType(const String& property, const String& de
tail); | 68 static String incorrectPropertyType(const String& property, const String& de
tail); |
69 | 69 |
70 template <typename NumberType> | 70 template <typename NumberType> |
71 static String indexExceedsMaximumBound(const char* name, NumberType given, N
umberType bound) | 71 static String indexExceedsMaximumBound(const char* name, NumberType given, N
umberType bound) |
72 { | 72 { |
73 bool eq = given == bound; | 73 bool eq = given == bound; |
74 StringBuilder result; | 74 StringBuilder result; |
75 result.append("The "); | 75 result.appendLiteral("The "); |
76 result.append(name); | 76 result.append(name); |
77 result.append(" provided ("); | 77 result.appendLiteral(" provided ("); |
78 result.append(formatNumber(given)); | 78 result.append(formatNumber(given)); |
79 result.append(") is greater than "); | 79 result.appendLiteral(") is greater than "); |
80 result.append(eq ? "or equal to " : ""); | 80 result.append(eq ? "or equal to " : ""); |
81 result.append("the maximum bound ("); | 81 result.appendLiteral("the maximum bound ("); |
82 result.append(formatNumber(bound)); | 82 result.append(formatNumber(bound)); |
83 result.append(")."); | 83 result.appendLiteral(")."); |
84 return result.toString(); | 84 return result.toString(); |
85 } | 85 } |
86 | 86 |
87 template <typename NumberType> | 87 template <typename NumberType> |
88 static String indexExceedsMinimumBound(const char* name, NumberType given, N
umberType bound) | 88 static String indexExceedsMinimumBound(const char* name, NumberType given, N
umberType bound) |
89 { | 89 { |
90 bool eq = given == bound; | 90 bool eq = given == bound; |
91 StringBuilder result; | 91 StringBuilder result; |
92 result.append("The "); | 92 result.appendLiteral("The "); |
93 result.append(name); | 93 result.append(name); |
94 result.append(" provided ("); | 94 result.appendLiteral(" provided ("); |
95 result.append(formatNumber(given)); | 95 result.append(formatNumber(given)); |
96 result.append(") is less than "); | 96 result.appendLiteral(") is less than "); |
97 result.append(eq ? "or equal to " : ""); | 97 result.append(eq ? "or equal to " : ""); |
98 result.append("the minimum bound ("); | 98 result.appendLiteral("the minimum bound ("); |
99 result.append(formatNumber(bound)); | 99 result.append(formatNumber(bound)); |
100 result.append(")."); | 100 result.appendLiteral(")."); |
101 return result.toString(); | 101 return result.toString(); |
102 } | 102 } |
103 | 103 |
104 template <typename NumberType> | 104 template <typename NumberType> |
105 static String indexOutsideRange(const char* name, NumberType given, NumberTy
pe lowerBound, BoundType lowerType, NumberType upperBound, BoundType upperType) | 105 static String indexOutsideRange(const char* name, NumberType given, NumberTy
pe lowerBound, BoundType lowerType, NumberType upperBound, BoundType upperType) |
106 { | 106 { |
107 StringBuilder result; | 107 StringBuilder result; |
108 result.append("The "); | 108 result.appendLiteral("The "); |
109 result.append(name); | 109 result.append(name); |
110 result.append(" provided ("); | 110 result.appendLiteral(" provided ("); |
111 result.append(formatNumber(given)); | 111 result.append(formatNumber(given)); |
112 result.append(") is outside the range "); | 112 result.appendLiteral(") is outside the range "); |
113 result.append(lowerType == ExclusiveBound ? '(' : '['); | 113 result.append(lowerType == ExclusiveBound ? '(' : '['); |
114 result.append(formatNumber(lowerBound)); | 114 result.append(formatNumber(lowerBound)); |
115 result.append(", "); | 115 result.appendLiteral(", "); |
116 result.append(formatNumber(upperBound)); | 116 result.append(formatNumber(upperBound)); |
117 result.append(upperType == ExclusiveBound ? ')' : ']'); | 117 result.append(upperType == ExclusiveBound ? ')' : ']'); |
118 result.append('.'); | 118 result.append('.'); |
119 return result.toString(); | 119 return result.toString(); |
120 } | 120 } |
121 | 121 |
122 static String invalidArity(const char* expected, unsigned provided); | 122 static String invalidArity(const char* expected, unsigned provided); |
123 | 123 |
124 // If > 0, the argument index that failed type check (1-indexed.) | 124 // If > 0, the argument index that failed type check (1-indexed.) |
125 // If == 0, a (non-argument) value (e.g., a setter) failed the same check. | 125 // If == 0, a (non-argument) value (e.g., a setter) failed the same check. |
(...skipping 29 matching lines...) Expand all Loading... |
155 | 155 |
156 static String ordinalNumber(int number); | 156 static String ordinalNumber(int number); |
157 }; | 157 }; |
158 | 158 |
159 template <> String ExceptionMessages::formatNumber<float>(float number); | 159 template <> String ExceptionMessages::formatNumber<float>(float number); |
160 template <> String ExceptionMessages::formatNumber<double>(double number); | 160 template <> String ExceptionMessages::formatNumber<double>(double number); |
161 | 161 |
162 } // namespace blink | 162 } // namespace blink |
163 | 163 |
164 #endif // ExceptionMessages_h | 164 #endif // ExceptionMessages_h |
OLD | NEW |