diff Core/JobsEngine/SetOfInstancesJob.cpp @ 2598:34dc57f4a7d2 jobs

simplification of JobStepResult
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 16 May 2018 16:23:20 +0200
parents ec09641d6f41
children 714dcddeb65f
line wrap: on
line diff
--- a/Core/JobsEngine/SetOfInstancesJob.cpp	Wed May 16 14:40:05 2018 +0200
+++ b/Core/JobsEngine/SetOfInstancesJob.cpp	Wed May 16 16:23:20 2018 +0200
@@ -113,7 +113,7 @@
   }
 
 
-  JobStepResult* SetOfInstancesJob::ExecuteStep()
+  JobStepResult SetOfInstancesJob::ExecuteStep()
   {
     if (!started_)
     {
@@ -125,13 +125,13 @@
     {
       // No instance to handle, we're done
       position_ = 1;
-      return new JobStepResult(JobStepCode_Success);
+      return JobStepResult::Success();
     }
 
     if (position_ >= instances_.size())
     {
       // Already done
-      return new JobStepResult(JobStepCode_Failure);
+      throw OrthancException(ErrorCode_BadSequenceOfCalls);
     }
 
     const std::string currentInstance = instances_[position_];
@@ -144,7 +144,7 @@
 
       if (!ok && !permissive_)
       {
-        throw OrthancException(ErrorCode_InternalError);
+        return JobStepResult::Failure(ErrorCode_InternalError);
       }
     }
     catch (OrthancException& e)
@@ -169,11 +169,11 @@
     if (position_ == instances_.size())
     {
       // We're done
-      return new JobStepResult(JobStepCode_Success);
+      return JobStepResult::Success();
     }
     else
     {
-      return new JobStepResult(JobStepCode_Continue);
+      return JobStepResult::Continue();
     }
   }