From 6dfb3ec082be2e74f414dc283ebd996cce214f24 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Sat, 9 Dec 2017 11:27:44 +0100 Subject: [PATCH] sonar: throw static exceptions --- src/kernel/activity/ExecImpl.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/kernel/activity/ExecImpl.cpp b/src/kernel/activity/ExecImpl.cpp index 5ecdf6a168..9dba149c18 100644 --- a/src/kernel/activity/ExecImpl.cpp +++ b/src/kernel/activity/ExecImpl.cpp @@ -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(); } -- 2.20.1