From: Martin Quinson Date: Sat, 25 Aug 2018 13:32:58 +0000 (+0200) Subject: allow to pass a std::string as message to Exceptions X-Git-Tag: v3_21~171 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/78edc5d868c7cb88107abcdc887180ff15c5228f allow to pass a std::string as message to Exceptions --- diff --git a/include/simgrid/Exception.hpp b/include/simgrid/Exception.hpp index 56eef781a8..e09cde016d 100644 --- a/include/simgrid/Exception.hpp +++ b/include/simgrid/Exception.hpp @@ -61,7 +61,7 @@ public: /** Ancestor class of all SimGrid exception */ class Exception : public std::runtime_error { public: - Exception(simgrid::xbt::ThrowPoint throwpoint, const char* message) + Exception(simgrid::xbt::ThrowPoint throwpoint, std::string message) : std::runtime_error(message), throwpoint_(throwpoint) { } @@ -95,7 +95,7 @@ public: * @param throwpoint Throw point (use XBT_THROW_POINT) * @param message Exception message */ - xbt_ex(simgrid::xbt::ThrowPoint throwpoint, const char* message) : simgrid::Exception(throwpoint, message) {} + xbt_ex(simgrid::xbt::ThrowPoint throwpoint, std::string message) : simgrid::Exception(throwpoint, message) {} ~xbt_ex(); // DO NOT define it here -- see ex.cpp for a rationale @@ -115,7 +115,7 @@ class TimeoutError : public xbt_ex { /** Exception raised when an host fails */ class HostFailureException : public xbt_ex { public: - HostFailureException(simgrid::xbt::ThrowPoint throwpoint, const char* message) : xbt_ex(throwpoint, message) + HostFailureException(simgrid::xbt::ThrowPoint throwpoint, std::string message) : xbt_ex(throwpoint, message) { category = host_error; } diff --git a/src/simix/ActorImpl.cpp b/src/simix/ActorImpl.cpp index 2f2b67c3d7..f8c6f8ae21 100644 --- a/src/simix/ActorImpl.cpp +++ b/src/simix/ActorImpl.cpp @@ -229,7 +229,8 @@ void ActorImpl::resume() smx_activity_t ActorImpl::sleep(double duration) { if (host_->is_off()) - THROWF(host_error, 0, "Host %s failed, you cannot sleep there.", host_->get_cname()); + throw new simgrid::HostFailureException(XBT_THROW_POINT, + std::string("Host ") + std::string(host_->get_cname())+" failed, you cannot sleep there."); simgrid::kernel::activity::SleepImpl* synchro = new simgrid::kernel::activity::SleepImpl(); synchro->host = host_; diff --git a/src/xbt/exception.cpp b/src/xbt/exception.cpp index 9ab411a271..d2712eef07 100644 --- a/src/xbt/exception.cpp +++ b/src/xbt/exception.cpp @@ -30,8 +30,7 @@ xbt_ex::~xbt_ex() = default; void _xbt_throw(char* message, xbt_errcat_t errcat, int value, const char* file, int line, const char* func) { - xbt_ex e(simgrid::xbt::ThrowPoint(file, line, func, simgrid::xbt::backtrace(), xbt_procname(), xbt_getpid()), - message); + xbt_ex e(simgrid::xbt::ThrowPoint(XBT_THROW_POINT), message); xbt_free(message); e.category = errcat; e.value = value;