# HG changeset patch # User Sebastien Jodogne # Date 1624883137 -7200 # Node ID 1db3b79d97bdc5a2ee74425e17b43c970a7e8d9f # Parent 3709565bee7fba6387640ac0dc1862066e12bcdf Error code and description of jobs are now saved into the Orthanc database diff -r 3709565bee7f -r 1db3b79d97bd NEWS --- a/NEWS Mon Jun 28 12:03:07 2021 +0200 +++ b/NEWS Mon Jun 28 14:25:37 2021 +0200 @@ -14,6 +14,7 @@ ----------- * Fix broken "Do lookup" button in Orthanc Explorer +* Error code and description of jobs are now saved into the Orthanc database Version 1.9.4 (2021-06-24) diff -r 3709565bee7f -r 1db3b79d97bd OrthancFramework/Sources/JobsEngine/JobsRegistry.cpp --- a/OrthancFramework/Sources/JobsEngine/JobsRegistry.cpp Mon Jun 28 12:03:07 2021 +0200 +++ b/OrthancFramework/Sources/JobsEngine/JobsRegistry.cpp Mon Jun 28 14:25:37 2021 +0200 @@ -39,6 +39,8 @@ static const char* CREATION_TIME = "CreationTime"; static const char* LAST_CHANGE_TIME = "LastChangeTime"; static const char* RUNTIME = "Runtime"; + static const char* ERROR_CODE = "ErrorCode"; + static const char* ERROR_DETAILS = "ErrorDetails"; class JobsRegistry::JobHandler : public boost::noncopyable @@ -276,6 +278,11 @@ target[CREATION_TIME] = boost::posix_time::to_iso_string(creationTime_); target[LAST_CHANGE_TIME] = boost::posix_time::to_iso_string(lastStateChangeTime_); target[RUNTIME] = static_cast(runtime_.total_milliseconds()); + + // New in Orthanc 1.9.5 + target[ERROR_CODE] = static_cast(lastStatus_.GetErrorCode()); + target[ERROR_DETAILS] = lastStatus_.GetDetails(); + return true; } else @@ -307,7 +314,23 @@ job_->GetJobType(jobType_); job_->Start(); - lastStatus_ = JobStatus(ErrorCode_Success, "", *job_); + ErrorCode errorCode; + if (serialized.isMember(ERROR_CODE)) + { + errorCode = static_cast(SerializationToolbox::ReadInteger(serialized, ERROR_CODE)); + } + else + { + errorCode = ErrorCode_Success; // Backward compatibility with Orthanc <= 1.9.4 + } + + std::string details; + if (serialized.isMember(ERROR_DETAILS)) // Backward compatibility with Orthanc <= 1.9.4 + { + details = SerializationToolbox::ReadString(serialized, ERROR_DETAILS); + } + + lastStatus_ = JobStatus(errorCode, details, *job_); } };