Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Define and use a more specific exception.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Mon, 6 Nov 2017 15:24:20 +0000 (16:24 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 8 Nov 2017 16:36:21 +0000 (17:36 +0100)
teshsuite/simix/generic_simcalls/generic_simcalls.cpp

index 3ae06a0..c7eb726 100644 (file)
@@ -18,6 +18,10 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(test, "my log messages");
 
 namespace example {
 
+class exception : public std::runtime_error {
+  using std::runtime_error::runtime_error;
+};
+
 /** Create a future which becomes ready when the date is reached */
 static
 simgrid::kernel::Future<void> kernel_wait_until(double date)
@@ -53,12 +57,11 @@ static int master(int argc, char *argv[])
     simgrid::simix::kernelSync([] {
       return kernel_wait_until(20).then([](simgrid::kernel::Future<void> future) {
         future.get();
-        throw std::runtime_error("Exception throwed from kernel_defer");
+        throw example::exception("Exception throwed from kernel_defer");
       });
     });
     XBT_ERROR("No exception caught!");
-  }
-  catch(std::runtime_error& e) {
+  } catch (const example::exception& e) {
     XBT_INFO("Exception caught: %s", e.what());
   }