utypes.cpp 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. // © 2016 and later: Unicode, Inc. and others.
  2. // License & terms of use: http://www.unicode.org/copyright.html
  3. /*
  4. ******************************************************************************
  5. *
  6. * Copyright (C) 1997-2015, International Business Machines
  7. * Corporation and others. All Rights Reserved.
  8. *
  9. ******************************************************************************
  10. *
  11. * FILE NAME : utypes.c (previously putil.c)
  12. *
  13. * Date Name Description
  14. * 10/07/2004 grhoten split from putil.c
  15. ******************************************************************************
  16. */
  17. #include "unicode/utypes.h"
  18. /* u_errorName() ------------------------------------------------------------ */
  19. static const char * const
  20. _uErrorInfoName[U_ERROR_WARNING_LIMIT-U_ERROR_WARNING_START]={
  21. "U_USING_FALLBACK_WARNING",
  22. "U_USING_DEFAULT_WARNING",
  23. "U_SAFECLONE_ALLOCATED_WARNING",
  24. "U_STATE_OLD_WARNING",
  25. "U_STRING_NOT_TERMINATED_WARNING",
  26. "U_SORT_KEY_TOO_SHORT_WARNING",
  27. "U_AMBIGUOUS_ALIAS_WARNING",
  28. "U_DIFFERENT_UCA_VERSION",
  29. "U_PLUGIN_CHANGED_LEVEL_WARNING",
  30. };
  31. static const char * const
  32. _uTransErrorName[U_PARSE_ERROR_LIMIT - U_PARSE_ERROR_START]={
  33. "U_BAD_VARIABLE_DEFINITION",
  34. "U_MALFORMED_RULE",
  35. "U_MALFORMED_SET",
  36. "U_MALFORMED_SYMBOL_REFERENCE",
  37. "U_MALFORMED_UNICODE_ESCAPE",
  38. "U_MALFORMED_VARIABLE_DEFINITION",
  39. "U_MALFORMED_VARIABLE_REFERENCE",
  40. "U_MISMATCHED_SEGMENT_DELIMITERS",
  41. "U_MISPLACED_ANCHOR_START",
  42. "U_MISPLACED_CURSOR_OFFSET",
  43. "U_MISPLACED_QUANTIFIER",
  44. "U_MISSING_OPERATOR",
  45. "U_MISSING_SEGMENT_CLOSE",
  46. "U_MULTIPLE_ANTE_CONTEXTS",
  47. "U_MULTIPLE_CURSORS",
  48. "U_MULTIPLE_POST_CONTEXTS",
  49. "U_TRAILING_BACKSLASH",
  50. "U_UNDEFINED_SEGMENT_REFERENCE",
  51. "U_UNDEFINED_VARIABLE",
  52. "U_UNQUOTED_SPECIAL",
  53. "U_UNTERMINATED_QUOTE",
  54. "U_RULE_MASK_ERROR",
  55. "U_MISPLACED_COMPOUND_FILTER",
  56. "U_MULTIPLE_COMPOUND_FILTERS",
  57. "U_INVALID_RBT_SYNTAX",
  58. "U_INVALID_PROPERTY_PATTERN",
  59. "U_MALFORMED_PRAGMA",
  60. "U_UNCLOSED_SEGMENT",
  61. "U_ILLEGAL_CHAR_IN_SEGMENT",
  62. "U_VARIABLE_RANGE_EXHAUSTED",
  63. "U_VARIABLE_RANGE_OVERLAP",
  64. "U_ILLEGAL_CHARACTER",
  65. "U_INTERNAL_TRANSLITERATOR_ERROR",
  66. "U_INVALID_ID",
  67. "U_INVALID_FUNCTION"
  68. };
  69. static const char * const
  70. _uErrorName[U_STANDARD_ERROR_LIMIT]={
  71. "U_ZERO_ERROR",
  72. "U_ILLEGAL_ARGUMENT_ERROR",
  73. "U_MISSING_RESOURCE_ERROR",
  74. "U_INVALID_FORMAT_ERROR",
  75. "U_FILE_ACCESS_ERROR",
  76. "U_INTERNAL_PROGRAM_ERROR",
  77. "U_MESSAGE_PARSE_ERROR",
  78. "U_MEMORY_ALLOCATION_ERROR",
  79. "U_INDEX_OUTOFBOUNDS_ERROR",
  80. "U_PARSE_ERROR",
  81. "U_INVALID_CHAR_FOUND",
  82. "U_TRUNCATED_CHAR_FOUND",
  83. "U_ILLEGAL_CHAR_FOUND",
  84. "U_INVALID_TABLE_FORMAT",
  85. "U_INVALID_TABLE_FILE",
  86. "U_BUFFER_OVERFLOW_ERROR",
  87. "U_UNSUPPORTED_ERROR",
  88. "U_RESOURCE_TYPE_MISMATCH",
  89. "U_ILLEGAL_ESCAPE_SEQUENCE",
  90. "U_UNSUPPORTED_ESCAPE_SEQUENCE",
  91. "U_NO_SPACE_AVAILABLE",
  92. "U_CE_NOT_FOUND_ERROR",
  93. "U_PRIMARY_TOO_LONG_ERROR",
  94. "U_STATE_TOO_OLD_ERROR",
  95. "U_TOO_MANY_ALIASES_ERROR",
  96. "U_ENUM_OUT_OF_SYNC_ERROR",
  97. "U_INVARIANT_CONVERSION_ERROR",
  98. "U_INVALID_STATE_ERROR",
  99. "U_COLLATOR_VERSION_MISMATCH",
  100. "U_USELESS_COLLATOR_ERROR",
  101. "U_NO_WRITE_PERMISSION",
  102. "U_INPUT_TOO_LONG_ERROR"
  103. };
  104. static const char * const
  105. _uFmtErrorName[U_FMT_PARSE_ERROR_LIMIT - U_FMT_PARSE_ERROR_START] = {
  106. "U_UNEXPECTED_TOKEN",
  107. "U_MULTIPLE_DECIMAL_SEPARATORS",
  108. "U_MULTIPLE_EXPONENTIAL_SYMBOLS",
  109. "U_MALFORMED_EXPONENTIAL_PATTERN",
  110. "U_MULTIPLE_PERCENT_SYMBOLS",
  111. "U_MULTIPLE_PERMILL_SYMBOLS",
  112. "U_MULTIPLE_PAD_SPECIFIERS",
  113. "U_PATTERN_SYNTAX_ERROR",
  114. "U_ILLEGAL_PAD_POSITION",
  115. "U_UNMATCHED_BRACES",
  116. "U_UNSUPPORTED_PROPERTY",
  117. "U_UNSUPPORTED_ATTRIBUTE",
  118. "U_ARGUMENT_TYPE_MISMATCH",
  119. "U_DUPLICATE_KEYWORD",
  120. "U_UNDEFINED_KEYWORD",
  121. "U_DEFAULT_KEYWORD_MISSING",
  122. "U_DECIMAL_NUMBER_SYNTAX_ERROR",
  123. "U_FORMAT_INEXACT_ERROR",
  124. "U_NUMBER_ARG_OUTOFBOUNDS_ERROR",
  125. "U_NUMBER_SKELETON_SYNTAX_ERROR",
  126. "U_MF_UNRESOLVED_VARIABLE_ERROR",
  127. "U_MF_SYNTAX_ERROR",
  128. "U_MF_UNKNOWN_FUNCTION_ERROR",
  129. "U_MF_VARIANT_KEY_MISMATCH_ERROR",
  130. "U_MF_FORMATTING_ERROR",
  131. "U_MF_NONEXHAUSTIVE_PATTERN_ERROR",
  132. "U_MF_DUPLICATE_OPTION_NAME_ERROR",
  133. "U_MF_SELECTOR_ERROR",
  134. "U_MF_MISSING_SELECTOR_ANNOTATION_ERROR",
  135. "U_MF_DUPLICATE_DECLARATION_ERROR",
  136. "U_MF_OPERAND_MISMATCH_ERROR",
  137. "U_MF_UNSUPPORTED_STATEMENT_ERROR",
  138. "U_MF_UNSUPPORTED_EXPRESSION_ERROR"
  139. };
  140. static const char * const
  141. _uBrkErrorName[U_BRK_ERROR_LIMIT - U_BRK_ERROR_START] = {
  142. "U_BRK_INTERNAL_ERROR",
  143. "U_BRK_HEX_DIGITS_EXPECTED",
  144. "U_BRK_SEMICOLON_EXPECTED",
  145. "U_BRK_RULE_SYNTAX",
  146. "U_BRK_UNCLOSED_SET",
  147. "U_BRK_ASSIGN_ERROR",
  148. "U_BRK_VARIABLE_REDFINITION",
  149. "U_BRK_MISMATCHED_PAREN",
  150. "U_BRK_NEW_LINE_IN_QUOTED_STRING",
  151. "U_BRK_UNDEFINED_VARIABLE",
  152. "U_BRK_INIT_ERROR",
  153. "U_BRK_RULE_EMPTY_SET",
  154. "U_BRK_UNRECOGNIZED_OPTION",
  155. "U_BRK_MALFORMED_RULE_TAG"
  156. };
  157. static const char * const
  158. _uRegexErrorName[U_REGEX_ERROR_LIMIT - U_REGEX_ERROR_START] = {
  159. "U_REGEX_INTERNAL_ERROR",
  160. "U_REGEX_RULE_SYNTAX",
  161. "U_REGEX_INVALID_STATE",
  162. "U_REGEX_BAD_ESCAPE_SEQUENCE",
  163. "U_REGEX_PROPERTY_SYNTAX",
  164. "U_REGEX_UNIMPLEMENTED",
  165. "U_REGEX_MISMATCHED_PAREN",
  166. "U_REGEX_NUMBER_TOO_BIG",
  167. "U_REGEX_BAD_INTERVAL",
  168. "U_REGEX_MAX_LT_MIN",
  169. "U_REGEX_INVALID_BACK_REF",
  170. "U_REGEX_INVALID_FLAG",
  171. "U_REGEX_LOOK_BEHIND_LIMIT",
  172. "U_REGEX_SET_CONTAINS_STRING",
  173. "U_REGEX_OCTAL_TOO_BIG",
  174. "U_REGEX_MISSING_CLOSE_BRACKET",
  175. "U_REGEX_INVALID_RANGE",
  176. "U_REGEX_STACK_OVERFLOW",
  177. "U_REGEX_TIME_OUT",
  178. "U_REGEX_STOPPED_BY_CALLER",
  179. "U_REGEX_PATTERN_TOO_BIG",
  180. "U_REGEX_INVALID_CAPTURE_GROUP_NAME"
  181. };
  182. static const char * const
  183. _uIDNAErrorName[U_IDNA_ERROR_LIMIT - U_IDNA_ERROR_START] = {
  184. "U_STRINGPREP_PROHIBITED_ERROR",
  185. "U_STRINGPREP_UNASSIGNED_ERROR",
  186. "U_STRINGPREP_CHECK_BIDI_ERROR",
  187. "U_IDNA_STD3_ASCII_RULES_ERROR",
  188. "U_IDNA_ACE_PREFIX_ERROR",
  189. "U_IDNA_VERIFICATION_ERROR",
  190. "U_IDNA_LABEL_TOO_LONG_ERROR",
  191. "U_IDNA_ZERO_LENGTH_LABEL_ERROR",
  192. "U_IDNA_DOMAIN_NAME_TOO_LONG_ERROR"
  193. };
  194. static const char * const
  195. _uPluginErrorName[U_PLUGIN_ERROR_LIMIT - U_PLUGIN_ERROR_START] = {
  196. "U_PLUGIN_TOO_HIGH",
  197. "U_PLUGIN_DIDNT_SET_LEVEL",
  198. };
  199. U_CAPI const char * U_EXPORT2
  200. u_errorName(UErrorCode code) {
  201. if(U_ZERO_ERROR <= code && code < U_STANDARD_ERROR_LIMIT) {
  202. return _uErrorName[code];
  203. } else if(U_ERROR_WARNING_START <= code && code < U_ERROR_WARNING_LIMIT) {
  204. return _uErrorInfoName[code - U_ERROR_WARNING_START];
  205. } else if(U_PARSE_ERROR_START <= code && code < U_PARSE_ERROR_LIMIT){
  206. return _uTransErrorName[code - U_PARSE_ERROR_START];
  207. } else if(U_FMT_PARSE_ERROR_START <= code && code < U_FMT_PARSE_ERROR_LIMIT){
  208. return _uFmtErrorName[code - U_FMT_PARSE_ERROR_START];
  209. } else if (U_BRK_ERROR_START <= code && code < U_BRK_ERROR_LIMIT){
  210. return _uBrkErrorName[code - U_BRK_ERROR_START];
  211. } else if (U_REGEX_ERROR_START <= code && code < U_REGEX_ERROR_LIMIT) {
  212. return _uRegexErrorName[code - U_REGEX_ERROR_START];
  213. } else if(U_IDNA_ERROR_START <= code && code < U_IDNA_ERROR_LIMIT) {
  214. return _uIDNAErrorName[code - U_IDNA_ERROR_START];
  215. } else if(U_PLUGIN_ERROR_START <= code && code < U_PLUGIN_ERROR_LIMIT) {
  216. return _uPluginErrorName[code - U_PLUGIN_ERROR_START];
  217. } else {
  218. return "[BOGUS UErrorCode]";
  219. }
  220. }
  221. /*
  222. * Hey, Emacs, please set the following:
  223. *
  224. * Local Variables:
  225. * indent-tabs-mode: nil
  226. * End:
  227. *
  228. */