diff Core/JobsEngine/JobStatus.cpp @ 2663:228e2783ce83 jobs

some jobs might not be serializable
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 07 Jun 2018 18:18:02 +0200
parents e1893d31652a
children 4e43e67f8ecf
line wrap: on
line diff
--- a/Core/JobsEngine/JobStatus.cpp	Thu Jun 07 17:47:41 2018 +0200
+++ b/Core/JobsEngine/JobStatus.cpp	Thu Jun 07 18:18:02 2018 +0200
@@ -34,6 +34,8 @@
 #include "../PrecompiledHeaders.h"
 #include "JobStatus.h"
 
+#include "../OrthancException.h"
+
 namespace Orthanc
 {
   JobStatus::JobStatus() :
@@ -41,7 +43,7 @@
     progress_(0),
     jobType_("Invalid"),
     publicContent_(Json::objectValue),
-    serialized_(Json::objectValue)
+    hasSerialized_(false)
   {
   }
 
@@ -64,6 +66,20 @@
 
     job.GetJobType(jobType_);
     job.GetPublicContent(publicContent_);
-    job.Serialize(serialized_);
+
+    hasSerialized_ = job.Serialize(serialized_);
+  }
+
+
+  const Json::Value& JobStatus::GetSerialized() const
+  {
+    if (!hasSerialized_)
+    {
+      throw OrthancException(ErrorCode_BadSequenceOfCalls);
+    }
+    else
+    {
+      return serialized_;
+    }
   }
 }