Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Catch specialized exceptions instead of generic xbt_ex.
[simgrid.git] / examples / s4u / platform-failures / s4u-platform-failures.cpp
index ceea314..b8004c6 100644 (file)
@@ -9,9 +9,10 @@
  * To set such a profile, the first way is to use a file in the XML, while the second is to use the programmatic
  * interface. Once this profile is in place, the resource will automatically be turned on and off.
  *
- * The actors running on an host that is turned off will receive a simgrid::HostFailureException. Since we specified
- * on_failure="RESTART" for each actors in the XML file, they will be automatically restarted when the host starts
- * again.
+ * The actors running on an host that is turned off are forcefully killed
+ * once their on_exit callbacks are executed. They cannot avoid this fate.
+ * Since we specified on_failure="RESTART" for each actors in the XML file,
+ * they will be automatically restarted when the host starts again.
  *
  * Communications using failed links will .. fail.
  */
@@ -43,11 +44,9 @@ static int master(int argc, char* argv[])
     } catch (const simgrid::TimeoutError&) {
       delete payload;
       XBT_INFO("Mmh. Got timeouted while speaking to '%s'. Nevermind. Let's keep going!", mailbox->get_cname());
-    } catch (xbt_ex& e) {
-      if (e.category != network_error)
-        xbt_die("Unexpected behavior");
-      XBT_INFO("Mmh. The communication with '%s' failed. Nevermind. Let's keep going!", mailbox->get_cname());
+    } catch (const simgrid::NetworkFailureException&) {
       delete payload;
+      XBT_INFO("Mmh. The communication with '%s' failed. Nevermind. Let's keep going!", mailbox->get_cname());
     }
   }
 
@@ -61,10 +60,8 @@ static int master(int argc, char* argv[])
     } catch (const simgrid::TimeoutError&) {
       delete payload;
       XBT_INFO("Mmh. Got timeouted while speaking to '%s'. Nevermind. Let's keep going!", mailbox->get_cname());
-    } catch (xbt_ex& e) {
+    } catch (const simgrid::NetworkFailureException&) {
       delete payload;
-      if (e.category != network_error)
-        xbt_die("Unexpected behavior");
       XBT_INFO("Mmh. Something went wrong with '%s'. Nevermind. Let's keep going!", mailbox->get_cname());
     }
   }
@@ -95,9 +92,7 @@ static int worker(int argc, char* argv[])
       XBT_INFO("Start execution...");
       simgrid::s4u::this_actor::execute(comp_size);
       XBT_INFO("Execution complete.");
-    } catch (xbt_ex& e) {
-      if (e.category != network_error)
-        xbt_die("Unexpected behavior. Category: %s", xbt_ex_catname(e.category));
+    } catch (const simgrid::NetworkFailureException&) {
       XBT_INFO("Mmh. Something went wrong. Nevermind. Let's keep going!");
     }
   }