Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
sonar: throw static exceptions
authorMartin Quinson <martin.quinson@loria.fr>
Sat, 9 Dec 2017 10:27:44 +0000 (11:27 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Sat, 9 Dec 2017 10:28:24 +0000 (11:28 +0100)
src/kernel/activity/ExecImpl.cpp

index 5ecdf6a..9dba149 100644 (file)
@@ -43,12 +43,13 @@ void simgrid::kernel::activity::ExecImpl::resume()
 
 double simgrid::kernel::activity::ExecImpl::remains()
 {
-  if (host_ == nullptr) // parallel task: their remain is not in flops (we'd need a vector to express it this way
-                        // instead of a scalar), but between 0 and 1
-    throw new std::logic_error(
-        "The remaining work on parallel tasks cannot be defined as a scalar amount of flops (it's a vector). "
-        "So parallel_task->remains() is not defined. "
-        "You are probably looking for parallel_task->remainingRatio().");
+  static std::logic_error e(
+      "The remaining work on parallel tasks cannot be defined as a scalar amount of flops (it's a vector). "
+      "So parallel_task->remains() is not defined. "
+      "You are probably looking for parallel_task->remainingRatio().");
+
+  if (host_ == nullptr) // parallel task: their remain is not in flops (we'd need a vector for that, not a scalar)
+    throw &e;
   else // sequential task: everything's fine
     return surfAction_->getRemains();
 }