diff --git a/include/resource_data.h b/include/resource_data.h index 459a853..b52b9bd 100644 --- a/include/resource_data.h +++ b/include/resource_data.h @@ -36,6 +36,8 @@ const static std::string JSON_EXTENSION = ".json"; const static std::string SEPARATOR = "/"; const static std::string WIN_SEPARATOR = "\\"; const static std::string NEW_LINE_PATH = "\nat "; +const static std::string SOLUTIONS = "Solutions:"; +const static std::string SOLUTIONS_ARROW = "> "; const static std::string LONG_PATH_HEAD = "\\\\?\\"; const static int32_t VERSION_MAX_LEN = 128; const static int32_t INT_TO_BYTES = sizeof(uint32_t); diff --git a/src/config_parser.cpp b/src/config_parser.cpp index c66b537..d306621 100644 --- a/src/config_parser.cpp +++ b/src/config_parser.cpp @@ -400,6 +400,9 @@ bool ConfigParser::ParseJsonStringRef(cJSON *parent, const string &key, cJSON *n bool update = false; if (!GetRefIdFromString(value, update, JSON_STRING_IDS.at(key))) { cerr << "Error: '" << key << "' value " << value << " invalid value." << NEW_LINE_PATH << filePath_ << endl; + cerr << SOLUTIONS << endl; + cerr << SOLUTIONS_ARROW << "Please check the module.json5/config.json file in the src/main directory of the " + << GetModuleName() << "' module." << endl; return false; } if (update) { diff --git a/src/i_resource_compiler.cpp b/src/i_resource_compiler.cpp index 1e43666..54ac450 100644 --- a/src/i_resource_compiler.cpp +++ b/src/i_resource_compiler.cpp @@ -126,6 +126,8 @@ bool IResourceCompiler::MergeResourceItem(const ResourceItem &resourceItem) string idName = ResourceUtil::GetIdName(resourceItem.GetName(), resourceItem.GetResType()); if (!ResourceUtil::IsValidName(idName)) { cerr << "Error: invalid idName '" << idName << "'."<< NEW_LINE_PATH << resourceItem.GetFilePath() << endl; + cerr << SOLUTIONS << endl; + cerr << SOLUTIONS_ARROW << "Modify the name '" << idName << "' to match [a-zA-Z0-9_]." << endl; return false; } auto item = nameInfos_.find(make_pair(resourceItem.GetResType(), idName)); diff --git a/src/id_defined_parser.cpp b/src/id_defined_parser.cpp index 41a07f5..bb34e16 100755 --- a/src/id_defined_parser.cpp +++ b/src/id_defined_parser.cpp @@ -250,6 +250,8 @@ bool IdDefinedParser::ParseName(const cJSON *name, ResourceId &resourceId) (static_cast(resourceId.id) & static_cast(START_SYS_ID)) == START_SYS_ID && !ResourceUtil::IsValidName(resourceId.name)) { cerr << "Error: id_defined.json."<< endl; + cerr << SOLUTIONS << endl; + cerr << SOLUTIONS_ARROW << "Modify the name '" << resourceId.name << "' to match [a-zA-Z0-9_]." << endl; return false; } return true; diff --git a/src/resource_util.cpp b/src/resource_util.cpp index 6db039d..29ac939 100644 --- a/src/resource_util.cpp +++ b/src/resource_util.cpp @@ -82,6 +82,9 @@ bool ResourceUtil::OpenJsonFile(const string &path, cJSON **root) *root = cJSON_Parse(jsonString.c_str()); if (!*root) { cerr << "Error: cJSON_Parse failed, please check the JSON file." << NEW_LINE_PATH << path << endl; + cerr << SOLUTIONS << endl; + cerr << SOLUTIONS_ARROW << "Check the JSON file and delete unnecessary commas (,)." << endl; + cerr << SOLUTIONS_ARROW << "Check the JSON file to make sure the root bracket is {}" << endl; ifs.close(); return false; } @@ -216,7 +219,7 @@ bool ResourceUtil::CreateDirs(const string &filePath) if (FileExist(filePath)) { return true; } - + if (!FileEntry::CreateDirs(filePath)) { cerr << "Error: create dir '" << filePath << "' failed, reason:" << strerror(errno) << endl; return false; @@ -446,7 +449,7 @@ bool ResourceUtil::IsIntValue(const cJSON *node) bool ResourceUtil::IsValidName(const string &name) { if (!regex_match(name, regex("[a-zA-Z0-9_]+"))) { - cerr << "Error: '" << name << "' only contain [a-zA-Z0-9_]." << endl; + cerr << "Error: the name '" << name << "' can only contain [a-zA-Z0-9_]." << endl; return false; } return true;