mirror of
https://github.com/openharmony/developtools_global_resource_tool.git
synced 2026-07-18 17:24:42 -04:00
optimize error message
Signed-off-by: liduo <liduo29@huawei.com> Change-Id: If81f2189e3fb1b6cf7f0aa33f6dc78e045d77732
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -250,6 +250,8 @@ bool IdDefinedParser::ParseName(const cJSON *name, ResourceId &resourceId)
|
||||
(static_cast<uint64_t>(resourceId.id) & static_cast<uint64_t>(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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user