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