!236 优化错误信息

Merge pull request !236 from liduo/update_error_messages
This commit is contained in:
openharmony_ci
2025-05-23 06:05:21 +00:00
committed by Gitee
+56 -59
View File
@@ -47,7 +47,7 @@ const std::map<uint32_t, ErrorInfo> ERRORS_MAP = {
{ ERR_CODE_JSON_FORMAT_ERROR,
{ ERR_CODE_JSON_FORMAT_ERROR,
ERR_TYPE_CONFIG,
"Failed to parse the JSON file, format is incorrect.",
"Failed to parse the JSON file: incorrect format.",
"",
{ "Check the JSON file and delete unnecessary commas (,).",
"Check the JSON file to make sure the root bracket is {}." },
@@ -55,7 +55,7 @@ const std::map<uint32_t, ErrorInfo> ERRORS_MAP = {
{ ERR_CODE_JSON_NODE_MISMATCH,
{ ERR_CODE_JSON_NODE_MISMATCH,
ERR_TYPE_CONFIG,
"The value type of node '%s' does not match, expected type: %s.",
"The value type of node '%s' does not match. Expected type: %s.",
"",
{},
{} } },
@@ -66,51 +66,46 @@ const std::map<uint32_t, ErrorInfo> ERRORS_MAP = {
{ ERR_CODE_JSON_NOT_ONE_MEMBER,
{ ERR_CODE_JSON_NOT_ONE_MEMBER,
ERR_TYPE_CONFIG,
"The node '%s' of the JSON file can only have one member.",
"The node '%s' in the JSON file can only have one member.",
"",
{},
{} } },
{ ERR_CODE_JSON_INVALID_NODE_NAME,
{ ERR_CODE_JSON_INVALID_NODE_NAME,
ERR_TYPE_CONFIG,
"Invalid node name '%s', it should be one of %s.",
"",
{},
{} } },
{ ERR_CODE_JSON_INVALID_NODE_NAME, ERR_TYPE_CONFIG, "Invalid node name '%s'. Valid values: %s.", "", {}, {} } },
// 11204xxx
{ ERR_CODE_CREATE_FILE_ERROR,
{ ERR_CODE_CREATE_FILE_ERROR,
ERR_TYPE_FILE_RESOURCE,
"Failed to create directory or file '%s', %s.",
"Failed to create the directory or file '%s', %s.",
"",
{ "Make sure the file path is correct and has access permissions." },
{} } },
{ ERR_CODE_REMOVE_FILE_ERROR,
{ ERR_CODE_REMOVE_FILE_ERROR,
ERR_TYPE_FILE_RESOURCE,
"Failed to delete directory or file '%s', %s.",
"Failed to delete the directory or file '%s', %s.",
"",
{ "Make sure the file path is correct and has access permissions." },
{} } },
{ ERR_CODE_COPY_FILE_ERROR,
{ ERR_CODE_COPY_FILE_ERROR,
ERR_TYPE_FILE_RESOURCE,
"Failed to copy file from '%s' to '%s', %s.",
"Failed to copy the file from '%s' to '%s', %s.",
"",
{ "Make sure the src and dest file path is correct and has access permissions." },
{} } },
{ ERR_CODE_OPEN_FILE_ERROR,
{ ERR_CODE_OPEN_FILE_ERROR,
ERR_TYPE_FILE_RESOURCE,
"Failed to open file '%s', %s.",
"Failed to open the file '%s', %s.",
"",
{ "Make sure the file path is correct and has access permissions." },
{} } },
{ ERR_CODE_READ_FILE_ERROR,
{ ERR_CODE_READ_FILE_ERROR,
ERR_TYPE_FILE_RESOURCE,
"Failed to read file '%s', %s.",
"Failed to read the file '%s', %s.",
"",
{ "Make sure the file content is correct." },
{} } },
@@ -133,7 +128,7 @@ const std::map<uint32_t, ErrorInfo> ERRORS_MAP = {
{ ERR_CODE_MISSING_ARGUMENT,
{ ERR_CODE_MISSING_ARGUMENT,
ERR_TYPE_COMMAND_PARSE,
"Option '%s' should have a argument.",
"Option '%s' requires an argument.",
"",
{ "For details, see the help with option -h/--help." },
{} } },
@@ -175,21 +170,21 @@ const std::map<uint32_t, ErrorInfo> ERRORS_MAP = {
{ ERR_CODE_DOUBLE_OUTPUT,
{ ERR_CODE_DOUBLE_OUTPUT,
ERR_TYPE_COMMAND_PARSE,
"The output path '%s' and '%s' conflict.",
"The output paths '%s' and '%s' conflict.",
"",
{ "Make sure the option -o/--outputPath only specified once." },
{} } },
{ ERR_CODE_DUPLICATE_RES_HEADER,
{ ERR_CODE_DUPLICATE_RES_HEADER,
ERR_TYPE_COMMAND_PARSE,
"Duplicated res header path '%s'.",
"Duplicated resource header path '%s'.",
"",
{ "Make sure the path of option -r/--resHeader is unique." },
{} } },
{ ERR_CODE_DOUBLE_MODULES,
{ ERR_CODE_DOUBLE_MODULES,
ERR_TYPE_COMMAND_PARSE,
"The module name '%s' and '%s' conflict.",
"The module names '%s' and '%s' conflict.",
"",
{ "Make sure the option -m/--modules only specified once." },
{} } },
@@ -203,14 +198,14 @@ const std::map<uint32_t, ErrorInfo> ERRORS_MAP = {
{ ERR_CODE_DOUBLE_CONFIG_JSON,
{ ERR_CODE_DOUBLE_CONFIG_JSON,
ERR_TYPE_COMMAND_PARSE,
"The module.json(in Stage Model) or config.json(in FA Model) path '%s' and '%s' conflict.",
"The paths '%s' and '%s' of the module.json(in Stage Model) or config.json(in FA Model) file conflict.",
"",
{ "Make sure the option -j/--json only specified once." },
{} } },
{ ERR_CODE_INVALID_START_ID,
{ ERR_CODE_INVALID_START_ID,
ERR_TYPE_COMMAND_PARSE,
"Invalid start id '%s', out of range.",
"Invalid start ID '%s'. It is out of range.",
"",
{ "Make sure the start id in the scope [0x01000000, 0x06FFFFFF) or [0x08000000, 0xFFFFFFFF)." },
{} } },
@@ -224,14 +219,14 @@ const std::map<uint32_t, ErrorInfo> ERRORS_MAP = {
{ ERR_CODE_DOUBLE_TARGET_CONFIG,
{ ERR_CODE_DOUBLE_TARGET_CONFIG,
ERR_TYPE_COMMAND_PARSE,
"The target config '%s' and '%s' conflict.",
"The target configurations '%s' and '%s' conflict.",
"",
{ "Make sure the option --target-config only specified once." },
{} } },
{ ERR_CODE_INVALID_TARGET_CONFIG,
{ ERR_CODE_INVALID_TARGET_CONFIG,
ERR_TYPE_COMMAND_PARSE,
"Invalid target config argument '%s'.The argument format of option --target-config is supposed to be like "
"Invalid target configuration argument '%s'. The argument format for option --target-config should be like "
"'Locale[zh_CN,en_US];Device[phone]'.",
"",
{ "For more information, see the developer documentation." },
@@ -253,7 +248,7 @@ const std::map<uint32_t, ErrorInfo> ERRORS_MAP = {
{ ERR_CODE_DOUBLE_COMPRESSION_PATH,
{ ERR_CODE_DOUBLE_COMPRESSION_PATH,
ERR_TYPE_COMMAND_PARSE,
"The compression JSON path '%s' and '%s' conflict.",
"The compression JSON paths '%s' and '%s' conflict.",
"",
{ "Make sure the option --compressed-config only specified once." },
{} } },
@@ -267,22 +262,22 @@ const std::map<uint32_t, ErrorInfo> ERRORS_MAP = {
{ ERR_CODE_EXCLUSIVE_OPTION,
{ ERR_CODE_EXCLUSIVE_OPTION,
ERR_TYPE_COMMAND_PARSE,
"Option '%s' and '%s' cannot be used together.",
"Options '%s' and '%s' cannot be used together.",
"",
{},
{} } },
{ ERR_CODE_PACKAGE_NAME_EMPTY,
{ ERR_CODE_PACKAGE_NAME_EMPTY,
ERR_TYPE_COMMAND_PARSE,
"The package name is empty, it should be specified with option -p/--packageName",
"The package name is empty. It should be specified with option -p/--packageName.",
"",
{ "Specifies the package name with option -p/--packageName." },
{} } },
{ ERR_CODE_RES_HEADER_PATH_EMPTY,
{ ERR_CODE_RES_HEADER_PATH_EMPTY,
ERR_TYPE_COMMAND_PARSE,
"The resource header path(like ./ResourceTable.js, ./ResrouceTable.h) is empty, it should be specified with "
"option -r/--resHeader.",
"The resource header path (for example, ./ResourceTable.js, ./ResourceTable.h) is empty. It should be specified"
" with option -r/--resHeader.",
"",
{ "Specifies header path with option -r/--resHeader." },
{} } },
@@ -296,14 +291,14 @@ const std::map<uint32_t, ErrorInfo> ERRORS_MAP = {
{ ERR_CODE_DUMP_INVALID_INPUT,
{ ERR_CODE_DUMP_INVALID_INPUT,
ERR_TYPE_COMMAND_PARSE,
"Invalid HAP path '%s' of the resource dump command.",
"Invalid HAP path '%s' in the resource dump command.",
"",
{ "Make sure the HAP path of dump command is correct." },
{} } },
{ ERR_CODE_INVALID_THREAD_COUNT,
{ ERR_CODE_INVALID_THREAD_COUNT,
ERR_TYPE_COMMAND_PARSE,
"Invalid thread count '%s', it should be an integer and greater than 0.",
"Invalid thread count '%s'. It should be an integer greater than 0.",
"",
{},
{} } },
@@ -319,137 +314,139 @@ const std::map<uint32_t, ErrorInfo> ERRORS_MAP = {
{ ERR_CODE_OUTPUT_EXIST,
{ ERR_CODE_OUTPUT_EXIST,
ERR_TYPE_RESOURCE_PACK,
"Output path exists, but option -f/--forceWrite not specified.",
"The output path exists. Specify option -f/--forceWrite to overwrite.",
"",
{ "Remove the exist output dir or use option -f to force write." },
{} } },
{ ERR_CODE_CONFIG_JSON_MISSING,
{ ERR_CODE_CONFIG_JSON_MISSING,
ERR_TYPE_RESOURCE_PACK,
"Multiple input paths, but the module.json(in Stage Model) or config.json(in FA Model) path is not specified "
"with option -j/--json.",
"There are multiple input paths, but the path of the module.json (in the stage model) or config.json "
"(in the FA model) file is not specified with option -j/--json.",
"",
{ "Specifies option -j/--json." },
{} } },
{ ERR_CODE_INVALID_MODULE_TYPE,
{ ERR_CODE_INVALID_MODULE_TYPE,
ERR_TYPE_RESOURCE_PACK,
"Invalid module type '%s', it should be one of [\"entry\", \"har\", \"shared\", \"feature\"].",
"Invalid module type '%s'. Valid values: [\"entry\", \"har\", \"shared\", \"feature\"].",
"",
{},
{} } },
{ ERR_CODE_EXCLUSIVE_START_ID,
{ ERR_CODE_EXCLUSIVE_START_ID,
ERR_TYPE_RESOURCE_PACK,
"The id_defined.json and the start id '%lu' specified with option -e/--startId conflict.",
"The start ID '%lu' specified by option -e/--startId conflict with the IDs in the id_defined.json file.",
"",
{ "Retain only one of the id_defined.json and the start id." },
{} } },
{ ERR_CODE_ID_DEFINED_INVALID_TYPE,
{ ERR_CODE_ID_DEFINED_INVALID_TYPE,
ERR_TYPE_RESOURCE_PACK,
"Invalid resource type '%s' in the id_defined.json, it should be one of %s.",
"Invalid resource type '%s' in the id_defined.json file. Valid values: %s.",
"",
{},
{} } },
{ ERR_CODE_ID_DEFINED_INVALID_ID,
{ ERR_CODE_ID_DEFINED_INVALID_ID,
ERR_TYPE_RESOURCE_PACK,
"Invalid id value '%s' in the id_defined.json, it shoud be a hex string, match the pattern "
"^0[xX][0-9a-fA-F]{8}, and in the scope [0x01000000,0x06FFFFFF] or [0x08000000,0xFFFFFFFF].",
"Invalid id value '%s' in the id_defined.json file. It should be a hexadecimal string, match the pattern "
"^0[xX][0-9a-fA-F]{8}, and be in the scope [0x01000000,0x06FFFFFF] or [0x08000000,0xFFFFFFFF].",
"",
{},
{} } },
{ ERR_CODE_ID_DEFINED_ORDER_MISMATCH,
{ ERR_CODE_ID_DEFINED_ORDER_MISMATCH,
ERR_TYPE_RESOURCE_PACK,
"The order value '%lu' in the id_defined.json does not match the record element sequence '%lu', "
"expected value: %lu.",
"The order value '%lu' in the id_defined.json file does not match the record element sequence '%lu'. "
"Expected value: %lu.",
"",
{ "Make sure the order value is same as the sequence." },
{} } },
{ ERR_CODE_ID_DEFINED_SAME_ID,
{ ERR_CODE_ID_DEFINED_SAME_ID,
ERR_TYPE_RESOURCE_PACK,
"The name '%s' and '%s' in the id_defined.json define the same ID.",
"The names '%s' and '%s' in the id_defined.json file define the same ID.",
"",
{},
{} } },
{ ERR_CODE_MODULE_NAME_NOT_FOUND,
{ ERR_CODE_MODULE_NAME_NOT_FOUND,
ERR_TYPE_RESOURCE_PACK,
"The module name '%s' not found in %s, which specifies with -m/--modules.",
"The module name '%s' is not found in %s, which is specified by -m/--modules.",
"",
{ "Make sure the module name in module.json(in Stage Model) or config.json(in FA Model) is correct." },
{} } },
{ ERR_CODE_INVALID_RESOURCE_PATH,
{ ERR_CODE_INVALID_RESOURCE_PATH,
ERR_TYPE_RESOURCE_PACK,
"Failed to scan resources, invalid path '%s', %s.",
"Failed to scan resources: invalid path '%s', %s.",
"",
{},
{} } },
{ ERR_CODE_INVALID_LIMIT_KEY,
{ ERR_CODE_INVALID_LIMIT_KEY,
ERR_TYPE_RESOURCE_PACK,
"Invalid qualifiers key '%s', it should match the pattern of qualifiers directory,for example zh_CN,en_US,etc.",
"Invalid qualifier key '%s'. It should match the pattern of the qualifiers directory, for example zh_CN or "
"en_US.",
"",
{ "For more information, see the developer documentation." },
{} } },
{ ERR_CODE_INVALID_RESOURCE_DIR,
{ ERR_CODE_INVALID_RESOURCE_DIR,
ERR_TYPE_RESOURCE_PACK,
"Invalid resource directory name '%s', it should be one of %s.",
"Invalid resource directory name '%s'. Valid values: %s.",
"",
{},
{} } },
{ ERR_CODE_INVALID_TRANSLATE_PRIORITY,
{ ERR_CODE_INVALID_TRANSLATE_PRIORITY,
ERR_TYPE_RESOURCE_PACK,
"Invalid translate priority value '%s', it should be one of %s.",
"Invalid translate priority value '%s'. Valid values: %s.",
"",
{},
{} } },
{ ERR_CODE_INVALID_ELEMENT_TYPE,
{ ERR_CODE_INVALID_ELEMENT_TYPE,
ERR_TYPE_RESOURCE_PACK,
"Unsupported element resource type '%s', it should be one of %s.",
"Unsupported element resource type '%s'. Valid values: %s.",
"",
{},
{} } },
{ ERR_CODE_INVALID_COLOR_VALUE,
{ ERR_CODE_INVALID_COLOR_VALUE,
ERR_TYPE_RESOURCE_PACK,
"Invalid color value '%s' of the resource '%s', it only supported reference '$color:xxx' or '#rgb','#argb',"
"'#rrggbb','#aarrggbb'.",
"Invalid color value '%s' of the resource '%s'. It can only reference '$color:xxx' or be '#rgb','#argb',"
"'#rrggbb', or '#aarrggbb'.",
"",
{},
{} } },
{ ERR_CODE_INVALID_RESOURCE_REF,
{ ERR_CODE_INVALID_RESOURCE_REF,
ERR_TYPE_RESOURCE_PACK,
"Invalid resource reference '%s', it only supported reference '%sxxx'.",
"Invalid resource reference '%s'. Supported reference: '%sxxx'.",
"",
{},
{} } },
{ ERR_CODE_PARENT_EMPTY,
{ ERR_CODE_PARENT_EMPTY,
ERR_TYPE_RESOURCE_PACK,
"The parent value of resource '%s' is empty, it should be a valid resource name.",
"The parent value of resource '%s' is empty. It should be a valid resource name.",
"",
{},
{} } },
{ ERR_CODE_ARRAY_TOO_LARGE,
{ ERR_CODE_ARRAY_TOO_LARGE,
ERR_TYPE_RESOURCE_PACK,
"The array resource '%s' is to large, the total length of the value of the array elements cannot exceed 65535.",
"The array resource '%s' is too large. The total length of the value of the array elements cannot exceed "
"65535.",
"",
{ "Separate the large array into multiple arrays." },
{} } },
{ ERR_CODE_INVALID_QUANTITY,
{ ERR_CODE_INVALID_QUANTITY,
ERR_TYPE_RESOURCE_PACK,
"Invalid quantity '%s' of the resource '%s', it should be one of %s.",
"Invalid quantity '%s' of the plural resource '%s'. Valid values: %s.",
"",
{},
{} } },
@@ -463,36 +460,36 @@ const std::map<uint32_t, ErrorInfo> ERRORS_MAP = {
{ ERR_CODE_QUANTITY_NO_OTHER,
{ ERR_CODE_QUANTITY_NO_OTHER,
ERR_TYPE_RESOURCE_PACK,
"The plural resource '%s' should contains 'other' quantity.",
"The plural resource '%s' should contain the 'other' quantity.",
"",
{},
{} } },
{ ERR_CODE_INVALID_SYMBOL,
{ ERR_CODE_INVALID_SYMBOL,
ERR_TYPE_RESOURCE_PACK,
"Invalid value '%d' of the symbol resource '%s', it should be in the scope [0xF0000,0xFFFFF] or "
"[0x100000,0x10FFFF].",
"Invalid value '%d' of the symbol resource '%s'. It should be in the scope [0xF0000,0xFFFFF] or "
"[0x100000,0x10FFFF]."
"",
{},
{} } },
{ ERR_CODE_INVALID_RESOURCE_NAME,
{ ERR_CODE_INVALID_RESOURCE_NAME,
ERR_TYPE_RESOURCE_PACK,
"Invalid resource name '%s', it should be match the pattern [a-zA-Z0-9_].",
"Invalid resource name '%s'. It should match the pattern [a-zA-Z0-9_].",
"",
{ "Modify the name to match the pattern [a-zA-Z0-9_]." },
{} } },
{ ERR_CODE_RESOURCE_DUPLICATE,
{ ERR_CODE_RESOURCE_DUPLICATE,
ERR_TYPE_RESOURCE_PACK,
"Resource '%s' conflict, first declared at '%s', but declare again at '%s'.",
"Resource '%s' conflict. It is first declared at '%s' and declared again at '%s'.",
"",
{ "Make sure the resource name of the same type is unique." },
{} } },
{ ERR_CODE_RESOURCE_ID_EXCEED,
{ ERR_CODE_RESOURCE_ID_EXCEED,
ERR_TYPE_RESOURCE_PACK,
"The resource id '%lu' exceed, greater than the max id '%lu'.",
"The resource ID '%lu' exceeds the maximum ID '%lu'.",
"",
{ "Delete useless resources and recompile.", "Specify a smaller start id." },
{} } },
@@ -520,7 +517,7 @@ const std::map<uint32_t, ErrorInfo> ERRORS_MAP = {
// 11212xxx
{ ERR_CODE_PARSE_HAP_ERROR,
{ ERR_CODE_PARSE_HAP_ERROR, ERR_TYPE_RESOURCE_DUMP, "Failed to parse the hap, %s.", "", {}, {} } },
{ ERR_CODE_PARSE_HAP_ERROR, ERR_TYPE_RESOURCE_DUMP, "Failed to parse the HAP, %s.", "", {}, {} } },
};
ErrorInfo GetError(const uint32_t &errCode)