Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Rely on template argument deduction (sonar, c++17).
[simgrid.git] / src / xbt / xbt_replay.cpp
index 90ccbda..41c6d57 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2021. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2022. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -81,7 +81,7 @@ static ReplayAction* get_action(const char* name)
         otherqueue = act->second;
       } else { // Damn. Create the queue of that guy
         otherqueue = new std::queue<ReplayAction*>();
-        action_queues.insert({evtname, otherqueue});
+        action_queues.try_emplace(evtname, otherqueue);
       }
       otherqueue->push(action);
     }
@@ -99,12 +99,17 @@ static ReplayAction* get_action(const char* name)
 static void handle_action(ReplayAction& action)
 {
   XBT_DEBUG("%s replays a %s action", action.at(0).c_str(), action.at(1).c_str());
-  action_fun function = action_funs.at(action.at(1));
+  action_fun function;
+  try {
+    function = action_funs.at(action.at(1));
+  } catch (const std::out_of_range&) {
+    xbt_die("Replay Error: action %s is unknown, please register it properly in the replay engine",  action.at(1).c_str());
+  }
   try {
     function(action);
-  } catch (const Exception& e) {
+  } catch (const Exception&) {
     action.clear();
-    xbt_die("Replay error:\n %s", e.what());
+    throw;
   }
 }
 
@@ -121,7 +126,7 @@ int replay_runner(const char* actor_name, const char* trace_filename)
                "any. Please use xbt_replay_set_tracefile().");
     while (true) {
       simgrid::xbt::ReplayAction* evt = simgrid::xbt::get_action(actor_name);
-      if (!evt)
+      if (not evt)
         break;
       simgrid::xbt::handle_action(*evt);
       delete evt;