From b0d71c8e1357d2e3cc26dad21c296d4cee27dbd2 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Mon, 6 Nov 2017 16:24:20 +0100 Subject: [PATCH] Define and use a more specific exception. --- teshsuite/simix/generic_simcalls/generic_simcalls.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/teshsuite/simix/generic_simcalls/generic_simcalls.cpp b/teshsuite/simix/generic_simcalls/generic_simcalls.cpp index 3ae06a0a6b..c7eb7260e5 100644 --- a/teshsuite/simix/generic_simcalls/generic_simcalls.cpp +++ b/teshsuite/simix/generic_simcalls/generic_simcalls.cpp @@ -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 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 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()); } -- 2.20.1