From: Arnaud Giersch Date: Mon, 6 Nov 2017 15:24:20 +0000 (+0100) Subject: Define and use a more specific exception. X-Git-Tag: v3.18~242^2~73 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/b0d71c8e1357d2e3cc26dad21c296d4cee27dbd2 Define and use a more specific exception. --- 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()); }