1 /* This file is part of the 'stringi' project.
2 * Copyright (c) 2013-2021, Marek Gagolewski <https://www.gagolewski.com>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 *
15 * 3. Neither the name of the copyright holder nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
21 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
26 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
27 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
28 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31
32
33 #include "stri_stringi.h"
34
35
36 /** Get ICU error name
37 *
38 * @param status error code
39 * @return string
40 *
41 * @version 0.1-?? (Marek Gagolewski)
42 *
43 * @version 0.4-1 (Marek Gagolewski, 2014-11-30)
44 * ICU warning info added
45 *
46 * @version 1.1.2 (Marek Gagolewski, 2017-01-07) _LIMIT, _COUNT deprecated
47 *
48 * @version 1.4.7 (Marek Gagolewski, 2020-08-21) Rename class, make
49 * independent from StriException
50 *
51 * TODO: these should all start with a lowercase letter and not end with a dot
52 */
getICUerrorName(UErrorCode status)53 const char* ICUError::getICUerrorName(UErrorCode status)
54 {
55 switch(status) {
56 case U_USING_FALLBACK_WARNING:
57 return "A resource bundle lookup returned a fallback result. (not an error)";
58 case U_USING_DEFAULT_WARNING:
59 return "A resource bundle lookup returned a result from the root locale. (not an error)";
60 case U_SAFECLONE_ALLOCATED_WARNING:
61 return "A SafeClone operation required allocating memory. (informational only)";
62 case U_STATE_OLD_WARNING:
63 return "ICU has to use compatibility layer to construct the service. Expect performance/memory usage degradation. Consider upgrading";
64 case U_STRING_NOT_TERMINATED_WARNING:
65 return "An output string could not be NUL-terminated because output length==destCapacity.";
66 case U_SORT_KEY_TOO_SHORT_WARNING:
67 return "Number of levels requested in getBound is higher than the number of levels in the sort key.";
68 case U_AMBIGUOUS_ALIAS_WARNING:
69 return "This converter alias can go to different converter implementations.";
70 case U_DIFFERENT_UCA_VERSION:
71 return "ucol_open encountered a mismatch between UCA version and collator image version, so the collator was constructed from rules. No impact to further function.";
72 case U_PLUGIN_CHANGED_LEVEL_WARNING:
73 return "A plugin caused a level change. May not be an error, but later plugins may not load.";
74 case U_ZERO_ERROR:
75 return "No error, no warning (why did stringi report that??? file a bug report, please; thanks!)";
76 case U_ILLEGAL_ARGUMENT_ERROR:
77 return "Illegal argument.";
78 case U_MISSING_RESOURCE_ERROR:
79 return "The requested ICU resource cannot be found.";
80 case U_INVALID_FORMAT_ERROR:
81 return "Data format is not what is expected.";
82 case U_FILE_ACCESS_ERROR: // udata.cpp only
83 return "The requested ICU resource file cannot be found.";
84 case U_INTERNAL_PROGRAM_ERROR:
85 return "Internal ICU error, might be a bug in the library code.";
86 case U_MESSAGE_PARSE_ERROR:
87 return "Unable to parse a message (message format).";
88 case U_MEMORY_ALLOCATION_ERROR:
89 return "Memory allocation error.";
90 case U_INDEX_OUTOFBOUNDS_ERROR:
91 return "Trying to access the index that is out of bounds.";
92 case U_PARSE_ERROR:
93 return "ICU Parse error.";
94 case U_INVALID_CHAR_FOUND:
95 return "Character conversion: Unmappable input sequence / Invalid character.";
96 case U_TRUNCATED_CHAR_FOUND:
97 return "Character conversion: Incomplete input sequence.";
98 case U_ILLEGAL_CHAR_FOUND:
99 return "Character conversion: Illegal input sequence/combination of input units.";
100 case U_INVALID_TABLE_FORMAT:
101 return "Conversion table file found, but corrupted.";
102 case U_INVALID_TABLE_FILE:
103 return "Conversion table file not found.";
104 case U_BUFFER_OVERFLOW_ERROR:
105 return "A result would not fit in the supplied buffer.";
106 case U_UNSUPPORTED_ERROR:
107 return "Requested operation not supported in current context.";
108 case U_RESOURCE_TYPE_MISMATCH:
109 return "An operation is requested over a resource that does not support it";
110 case U_ILLEGAL_ESCAPE_SEQUENCE:
111 return "ISO-2022 illegal escape sequence.";
112 case U_UNSUPPORTED_ESCAPE_SEQUENCE:
113 return "ISO-2022 unsupported escape sequence.";
114 case U_NO_SPACE_AVAILABLE:
115 return "No space available for in-buffer expansion for Arabic shaping.";
116 case U_CE_NOT_FOUND_ERROR:
117 return "Currently used only while setting variable top, but can be used generally.";
118 case U_PRIMARY_TOO_LONG_ERROR:
119 return "User tried to set variable top to a primary that is longer than two bytes.";
120 case U_STATE_TOO_OLD_ERROR:
121 return "ICU cannot construct a service from this state, as it is no longer supported.";
122 case U_TOO_MANY_ALIASES_ERROR:
123 return "There are too many aliases in the path to the requested resource. It is very possible that a circular alias definition has occurred";
124 case U_ENUM_OUT_OF_SYNC_ERROR:
125 return "UEnumeration out of sync with underlying collection.";
126 case U_INVARIANT_CONVERSION_ERROR:
127 return "Unable to convert a UChar* string to char* with the invariant converter.";
128 case U_INVALID_STATE_ERROR:
129 return "Requested operation can not be completed with ICU in its current state.";
130 case U_COLLATOR_VERSION_MISMATCH:
131 return "Collator version is not compatible with the base version.";
132 case U_USELESS_COLLATOR_ERROR:
133 return "Collator is options only and no base is specified.";
134 case U_NO_WRITE_PERMISSION:
135 return "Attempt to modify read-only or constant data.";
136 // case U_STANDARD_ERROR_LIMIT:
137 // return "This must always be the last value to indicate the limit for standard errors.";
138 case U_BAD_VARIABLE_DEFINITION:
139 return "Missing '$' or duplicate variable name.";
140 // case U_PARSE_ERROR_START:
141 // return "Start of Transliterator errors.";
142 case U_MALFORMED_RULE:
143 return "Elements of a rule are misplaced.";
144 case U_MALFORMED_SET:
145 return "A UnicodeSet pattern is invalid.";
146 // case U_MALFORMED_SYMBOL_REFERENCE:
147 // return "UNUSED as of ICU 2.4.";
148 case U_MALFORMED_UNICODE_ESCAPE:
149 return "A Unicode escape pattern is invalid.";
150 case U_MALFORMED_VARIABLE_DEFINITION:
151 return "A variable definition is invalid.";
152 case U_MALFORMED_VARIABLE_REFERENCE:
153 return "A variable reference is invalid.";
154 // case U_MISMATCHED_SEGMENT_DELIMITERS:
155 // return "UNUSED as of ICU 2.4.";
156 case U_MISPLACED_ANCHOR_START:
157 return "A start anchor appears at an illegal position.";
158 case U_MISPLACED_CURSOR_OFFSET:
159 return "A cursor offset occurs at an illegal position.";
160 case U_MISPLACED_QUANTIFIER:
161 return "A quantifier appears after a segment close delimiter.";
162 case U_MISSING_OPERATOR:
163 return "A rule contains no operator.";
164 // case U_MISSING_SEGMENT_CLOSE:
165 // return "UNUSED as of ICU 2.4.";
166 case U_MULTIPLE_ANTE_CONTEXTS:
167 return "More than one ante context.";
168 case U_MULTIPLE_CURSORS:
169 return "More than one cursor.";
170 case U_MULTIPLE_POST_CONTEXTS:
171 return "More than one post context.";
172 case U_TRAILING_BACKSLASH:
173 return "A dangling backslash.";
174 case U_UNDEFINED_SEGMENT_REFERENCE:
175 return "A segment reference does not correspond to a defined segment.";
176 case U_UNDEFINED_VARIABLE:
177 return "A variable reference does not correspond to a defined variable.";
178 case U_UNQUOTED_SPECIAL:
179 return "A special character was not quoted or escaped.";
180 case U_UNTERMINATED_QUOTE:
181 return "A closing single quote is missing.";
182 case U_RULE_MASK_ERROR:
183 return "A rule is hidden by an earlier more general rule.";
184 case U_MISPLACED_COMPOUND_FILTER:
185 return "A compound filter is in an invalid location.";
186 case U_MULTIPLE_COMPOUND_FILTERS:
187 return "More than one compound filter.";
188 case U_INVALID_RBT_SYNTAX:
189 return "A '::id' rule was passed to the RuleBasedTransliterator parser.";
190 // case U_INVALID_PROPERTY_PATTERN:
191 // return "UNUSED as of ICU 2.4.";
192 case U_MALFORMED_PRAGMA:
193 return "A 'use' pragma is invlalid.";
194 case U_UNCLOSED_SEGMENT:
195 return "A closing ')' is missing.";
196 // case U_ILLEGAL_CHAR_IN_SEGMENT:
197 // return "UNUSED as of ICU 2.4.";
198 case U_VARIABLE_RANGE_EXHAUSTED:
199 return "Too many stand-ins generated for the given variable range.";
200 case U_VARIABLE_RANGE_OVERLAP:
201 return "The variable range overlaps characters used in rules.";
202 case U_ILLEGAL_CHARACTER:
203 return "A special character is outside its allowed context.";
204 case U_INTERNAL_TRANSLITERATOR_ERROR:
205 return "Internal transliterator system error.";
206 case U_INVALID_ID:
207 return "A '::id' rule specifies an unknown transliterator.";
208 case U_INVALID_FUNCTION:
209 return "A '&fn()' rule specifies an unknown transliterator.";
210 // case U_PARSE_ERROR_LIMIT:
211 // return "The limit for Transliterator errors.";
212 case U_UNEXPECTED_TOKEN:
213 return "Syntax error in format pattern.";
214 // case U_FMT_PARSE_ERROR_START:
215 // return "Start of format library errors.";
216 case U_MULTIPLE_DECIMAL_SEPARATORS:
217 // case U_MULTIPLE_DECIMAL_SEPERATORS:
218 return "More than one decimal separator in number pattern.";
219 case U_MULTIPLE_EXPONENTIAL_SYMBOLS:
220 return "More than one exponent symbol in number pattern.";
221 case U_MALFORMED_EXPONENTIAL_PATTERN:
222 return "Grouping symbol in exponent pattern.";
223 case U_MULTIPLE_PERCENT_SYMBOLS:
224 return "More than one percent symbol in number pattern.";
225 case U_MULTIPLE_PERMILL_SYMBOLS:
226 return "More than one permill symbol in number pattern.";
227 case U_MULTIPLE_PAD_SPECIFIERS:
228 return "More than one pad symbol in number pattern.";
229 case U_PATTERN_SYNTAX_ERROR:
230 return "Syntax error in format pattern.";
231 case U_ILLEGAL_PAD_POSITION:
232 return "Pad symbol misplaced in number pattern.";
233 case U_UNMATCHED_BRACES:
234 return "Braces do not match in message pattern.";
235 // case U_UNSUPPORTED_PROPERTY:
236 // return "UNUSED as of ICU 2.4.";
237 // case U_UNSUPPORTED_ATTRIBUTE:
238 // return "UNUSED as of ICU 2.4.";
239 case U_ARGUMENT_TYPE_MISMATCH:
240 return "Argument name and argument index mismatch in MessageFormat functions.";
241 case U_DUPLICATE_KEYWORD:
242 return "Duplicate keyword in PluralFormat.";
243 case U_UNDEFINED_KEYWORD:
244 return "Undefined Plural keyword.";
245 case U_DEFAULT_KEYWORD_MISSING:
246 return "Missing DEFAULT rule in plural rules.";
247 case U_DECIMAL_NUMBER_SYNTAX_ERROR:
248 return "Decimal number syntax error.";
249 case U_FORMAT_INEXACT_ERROR:
250 return "Cannot format a number exactly and rounding mode is ROUND_UNNECESSARY.";
251 // case U_FMT_PARSE_ERROR_LIMIT:
252 // return "The limit for format library errors.";
253 case U_BRK_INTERNAL_ERROR:
254 return "An internal error (bug) was detected in ICU.";
255 // case U_BRK_ERROR_START:
256 // return "Start of codes indicating Break Iterator failures.";
257 case U_BRK_HEX_DIGITS_EXPECTED:
258 return "Hex digits expected as part of a escaped char in a rule.";
259 case U_BRK_SEMICOLON_EXPECTED:
260 return "Missing ';' at the end of a RBBI rule.";
261 case U_BRK_RULE_SYNTAX:
262 return "Syntax error in RBBI rule.";
263 case U_BRK_UNCLOSED_SET:
264 return "UnicodeSet witing an RBBI rule missing a closing ']'.";
265 case U_BRK_ASSIGN_ERROR:
266 return "Syntax error in RBBI rule assignment statement.";
267 case U_BRK_VARIABLE_REDFINITION:
268 return "RBBI rule $Variable redefined.";
269 case U_BRK_MISMATCHED_PAREN:
270 return "Mis-matched parentheses in an RBBI rule.";
271 case U_BRK_NEW_LINE_IN_QUOTED_STRING:
272 return "Missing closing quote in an RBBI rule.";
273 case U_BRK_UNDEFINED_VARIABLE:
274 return "Use of an undefined $Variable in an RBBI rule.";
275 case U_BRK_INIT_ERROR:
276 return "Initialization failure. Probable missing ICU Data.";
277 case U_BRK_RULE_EMPTY_SET:
278 return "Rule contains an empty Unicode Set.";
279 case U_BRK_UNRECOGNIZED_OPTION:
280 return "!!option in RBBI rules not recognized.";
281 case U_BRK_MALFORMED_RULE_TAG:
282 return "The {nnn} tag on a rule is malformed.";
283 // case U_BRK_ERROR_LIMIT:
284 // return "This must always be the last value to indicate the limit for Break Iterator failures.";
285 case U_REGEX_INTERNAL_ERROR:
286 return "An internal error (bug) was detected in ICU.";
287 // case U_REGEX_ERROR_START:
288 // return "Start of codes indicating regex failures.";
289 case U_REGEX_RULE_SYNTAX:
290 return "Syntax error in regex pattern.";
291 case U_REGEX_INVALID_STATE:
292 return "RegexMatcher in invalid state for requested operation.";
293 case U_REGEX_BAD_ESCAPE_SEQUENCE:
294 return "Unrecognized backslash escape sequence in pattern.";
295 case U_REGEX_PROPERTY_SYNTAX:
296 return "Incorrect Unicode property.";
297 case U_REGEX_UNIMPLEMENTED:
298 return "Use of regex feature that is not yet implemented.";
299 case U_REGEX_MISMATCHED_PAREN:
300 return "Incorrectly nested parentheses in regex pattern.";
301 case U_REGEX_NUMBER_TOO_BIG:
302 return "Decimal number is too large.";
303 case U_REGEX_BAD_INTERVAL:
304 return "Error in {min,max} interval.";
305 case U_REGEX_MAX_LT_MIN:
306 return "In {min,max}, max is less than min.";
307 case U_REGEX_INVALID_BACK_REF:
308 return "Back-reference to a non-existent capture group.";
309 case U_REGEX_INVALID_FLAG:
310 return "Invalid value for match mode flags.";
311 case U_REGEX_LOOK_BEHIND_LIMIT:
312 return "Look-Behind pattern matches must have a bounded maximum length.";
313 case U_REGEX_SET_CONTAINS_STRING:
314 return "Regexes cannot have UnicodeSets containing strings.";
315 // case U_REGEX_OCTAL_TOO_BIG: //Deprecated ICU 54. This error cannot occur.
316 // return "Octal character constants must be <= 0377.";
317 case U_REGEX_MISSING_CLOSE_BRACKET:
318 return "Missing closing bracket on a bracket expression.";
319 case U_REGEX_INVALID_RANGE:
320 return "In a character range [x-y], x is greater than y.";
321 case U_REGEX_STACK_OVERFLOW:
322 return "Regular expression backtrack stack overflow.";
323 case U_REGEX_TIME_OUT:
324 return "Maximum allowed match time exceeded.";
325 case U_REGEX_STOPPED_BY_CALLER:
326 return "Matching operation aborted by user callback fn.";
327 // case U_REGEX_ERROR_LIMIT:
328 // return "This must always be the last value to indicate the limit for regex errors.";
329 // case U_PLUGIN_ERROR_START:
330 // return "Start of codes indicating plugin failures.";
331 case U_PLUGIN_TOO_HIGH:
332 return "The plugin's level is too high to be loaded right now.";
333 case U_PLUGIN_DIDNT_SET_LEVEL:
334 return "The plugin didn't call uplug_setPlugLevel in response to a QUERY.";
335 // case U_PLUGIN_ERROR_LIMIT:
336 // return "This must always be the last value to indicate the limit for plugin errors. ";
337 #if U_ICU_VERSION_MAJOR_NUM>=55
338 case U_REGEX_PATTERN_TOO_BIG:
339 return "Pattern exceeds limits on size or complexity.";
340 case U_REGEX_INVALID_CAPTURE_GROUP_NAME:
341 return "Invalid capture group name.";
342 #endif
343 default:
344 return "Unknown ICU error or warning.";
345 }
346 }
347