Browse Source

modify geloge and report errmsg

pull/1243/head
liudingyan 5 years ago
parent
commit
1d3385f994
1 changed files with 16 additions and 0 deletions
  1. +16
    -0
      ge/omm/csa_interact.cc

+ 16
- 0
ge/omm/csa_interact.cc View File

@@ -79,6 +79,7 @@ Status CsaInteract::WriteJobState(JobState job_state, JobSubState job_sub_state,
ErrorModule error_module) {
if (!is_init_) {
GELOGE(INTERNAL_ERROR, "CsaInteract has not init, can't WriteJobState");
REPORT_INNER_ERROR("E19999", "CsaInteract has not init, can't WriteJobState");
return INTERNAL_ERROR;
}
if ((curr_state_ == JOBSTATE_FAILED) || (curr_state_ == JOBSTATE_KILLED)) {
@@ -107,7 +108,9 @@ Status CsaInteract::WriteJobState(JobState job_state, JobSubState job_sub_state,

content = content_json.dump();
} catch (const nlohmann::json::exception &e) {
GELOGE(INTERNAL_ERROR, "construct json object failed.");
GELOGE(INTERNAL_ERROR, "build jobstate content json string failed, exception:%s job_state:%u", e.what(), job_state);
REPORT_INNER_ERROR("E19999", "construct json object failed. exception:%s job_state:%u", e.what(), job_state);
return INTERNAL_ERROR;
}

@@ -169,6 +172,7 @@ void CsaInteract::WriteInternalErrorCode() {
Status CsaInteract::WriteHcomDetection(const std::string &content) {
if (!is_init_) {
GELOGE(INTERNAL_ERROR, "CsaInteract has not init, can't WriteJobState");
REPORT_INNER_ERROR("E19999", "WriteHcomDetection failed. CsaInteract has not init, can't WriteJobState");
return INTERNAL_ERROR;
}

@@ -192,28 +196,38 @@ Status CsaInteract::WriteFile(const std::string &file_name, const std::string &c
int32_t fd = mmOpen2(file_name.c_str(), flags, M_IRUSR | M_IWUSR | M_UMASK_GRPREAD);
if (fd == EN_ERROR) {
if (MakePath(file_name) != SUCCESS) {
GELOGE(INTERNAL_ERROR, "MakePath failed.");
GELOGE(INTERNAL_ERROR, "csainteract create file path fail, errno is %d", errno);
REPORT_CALL_ERROR("E19999", "MakePath failed. create file path fail, errno is %d", errno);
return INTERNAL_ERROR;
}
fd = mmOpen2(file_name.c_str(), flags, M_IRUSR | M_IWUSR | M_UMASK_GRPREAD);
if (fd == EN_ERROR) {
GELOGE(INTERNAL_ERROR, "mmOpen2 failed.");
GELOGE(INTERNAL_ERROR, "open file fail, errno is %d", errno);
REPORT_CALL_ERROR("E19999", "mmOpen2 failed. open file fail, errno is %d", errno);
return INTERNAL_ERROR;
}
}

mmSsize_t ret = mmWrite(fd, reinterpret_cast<void *>(const_cast<char *>(content.c_str())), content.length());
if (ret == EN_ERROR) {
GELOGE(INTERNAL_ERROR, "mmWrite failed.");
GELOGE(INTERNAL_ERROR, "write file fail, errno is %d", errno);
REPORT_CALL_ERROR("E19999", "mmWrite failed. write file fail, errno is %d", errno);
ret = mmClose(fd);
if (ret == EN_ERROR) {
GELOGE(INTERNAL_ERROR, "mmClose failed.");
GELOGE(INTERNAL_ERROR, "close file fail, error is %d", errno);
REPORT_CALL_ERROR("E19999", "mmClose failed. close file fail, error is %d", errno);
}
return INTERNAL_ERROR;
}
ret = mmClose(fd);
if (ret == EN_ERROR) {
GELOGE(INTERNAL_ERROR, "mmClose failed.");
GELOGE(INTERNAL_ERROR, "close file fail, error is %d", errno);
REPORT_CALL_ERROR("E19999", "mmClose failed. close file fail, error is %d", errno);
return INTERNAL_ERROR;
}

@@ -242,7 +256,9 @@ Status CsaInteract::MakePath(const std::string &file_name) {
std::string pre_path = file_path.substr(0, found + 1);
if (mmAccess(pre_path.c_str()) != EN_OK) {
if (mmMkdir(pre_path.c_str(), M_IRWXU) != EN_OK) {
GELOGE(INTERNAL_ERROR, "mmMkdir failed.");
GELOGE(INTERNAL_ERROR, "csainteract mkdir fail, errno is %d", errno);
REPORT_CALL_ERROR("E19999", "mmMkdir failed. mkdir fail, errno is %d", errno);
return INTERNAL_ERROR;
}
}


Loading…
Cancel
Save